diff --git a/sdk/compute/azure-mgmt-compute/CHANGELOG.md b/sdk/compute/azure-mgmt-compute/CHANGELOG.md index b62258de44ae..47c8b0b7a700 100644 --- a/sdk/compute/azure-mgmt-compute/CHANGELOG.md +++ b/sdk/compute/azure-mgmt-compute/CHANGELOG.md @@ -1,5 +1,61 @@ # Release History +## 35.0.0 (2025-04-12) + +### Features Added + + - Model AvailabilitySet has a new parameter system_data + - Model CapacityReservation has a new parameter system_data + - Model CapacityReservationGroup has a new parameter system_data + - Model DedicatedHost has a new parameter system_data + - Model DedicatedHostGroup has a new parameter system_data + - Model DedicatedHostSizeListResult has a new parameter next_link + - Model Disk has a new parameter system_data + - Model DiskAccess has a new parameter system_data + - Model DiskEncryptionSet has a new parameter system_data + - Model DiskRestorePoint has a new parameter system_data + - Model Image has a new parameter system_data + - Model PrivateEndpointConnection has a new parameter system_data + - Model ProximityPlacementGroup has a new parameter system_data + - Model ProxyResource has a new parameter system_data + - Model RestorePoint has a new parameter system_data + - Model RestorePointCollection has a new parameter system_data + - Model RestorePointSourceVMStorageProfile has a new parameter data_disk_list + - Model RollingUpgradeStatusInfo has a new parameter system_data + - Model Snapshot has a new parameter system_data + - Model SshPublicKeyResource has a new parameter system_data + - Model SystemData has a new parameter created_by + - Model SystemData has a new parameter created_by_type + - Model SystemData has a new parameter last_modified_by + - Model SystemData has a new parameter last_modified_by_type + - Model VirtualMachine has a new parameter e_tag + - Model VirtualMachine has a new parameter system_data + - Model VirtualMachineExtension has a new parameter system_data + - Model VirtualMachineExtensionImage has a new parameter system_data + - Model VirtualMachineRunCommand has a new parameter system_data + - Model VirtualMachineScaleSet has a new parameter e_tag + - Model VirtualMachineScaleSet has a new parameter system_data + - Model VirtualMachineScaleSetExtension has a new parameter vm_name + - Model VirtualMachineScaleSetExtension has a new parameter vm_type + - Model VirtualMachineScaleSetVM has a new parameter system_data + - Model VirtualMachineScaleSetVMExtension has a new parameter vm_name + - Model VirtualMachineScaleSetVMExtension has a new parameter vm_type + - Model VirtualMachineSizeListResult has a new parameter next_link + +### Breaking Changes + + - Model RestorePointSourceVMOSDisk no longer has parameter write_accelerator_enabled + - Model RestorePointSourceVMStorageProfile no longer has parameter data_disks + - Model VirtualMachine no longer has parameter etag + - Model VirtualMachineScaleSet no longer has parameter etag + - Model VirtualMachineScaleSetExtension no longer has parameter name + - Model VirtualMachineScaleSetExtension no longer has parameter type_properties_type + - Model VirtualMachineScaleSetVMExtension no longer has parameter name + - Model VirtualMachineScaleSetVMExtension no longer has parameter type_properties_type + - Parameter location of model VirtualMachineExtension is now required + - Parameter value of model PrivateEndpointConnectionListResult is now required + - Parameter value of model RestorePointCollectionListResult is now required + ## 34.1.0 (2025-03-24) ### Features Added diff --git a/sdk/compute/azure-mgmt-compute/README.md b/sdk/compute/azure-mgmt-compute/README.md index 91cf3d114ce6..2e009294e67b 100644 --- a/sdk/compute/azure-mgmt-compute/README.md +++ b/sdk/compute/azure-mgmt-compute/README.md @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/compute/azure-mgmt-compute/_meta.json b/sdk/compute/azure-mgmt-compute/_meta.json index af200276c392..92ac9a946537 100644 --- a/sdk/compute/azure-mgmt-compute/_meta.json +++ b/sdk/compute/azure-mgmt-compute/_meta.json @@ -1,12 +1,12 @@ { - "commit": "85dbdf68f1c3e1693bd94eff5e8a869f1a07ed78", + "commit": "7d74cb4d2be07eb752b609abefb874704815a5d4", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ "@autorest/python@6.27.4", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/compute/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/compute/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/compute/resource-manager/readme.md", "package-2024-03-02-only": "2024-07-16 12:23:13 -0400 602fb5144a226577186e35845422c11db9067cf8 Microsoft.Compute/DiskRP/stable/2024-03-02/snapshot.json", "package-2024-03-01-only": "2024-06-05 15:03:47 -0700 491e00d17f24909ecf5e1030b3833bed51224e92 Microsoft.Compute/ComputeRP/stable/2024-03-01/virtualMachineScaleSet.json", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py index 73c4c36bd53b..ce330953651e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py index 48f22e6dd1f7..25b5198c068e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py @@ -20140,7 +20140,8 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py index 413fb4402887..03e61dff7b9b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py @@ -69,6 +69,9 @@ DiskImageEncryption, DiskInstanceView, EncryptionImages, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, ExtendedLocation, Gallery, GalleryApplication, @@ -467,6 +470,9 @@ "DiskImageEncryption", "DiskInstanceView", "EncryptionImages", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ExtendedLocation", "Gallery", "GalleryApplication", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py index c0a29e88ce69..a8c01005cd9a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py @@ -2835,6 +2835,98 @@ def __init__( self.data_disk_images = data_disk_images +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.compute.v2021_07_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.compute.v2021_07_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.compute.v2021_07_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class ExtendedLocation(_serialization.Model): """The complex type of the extended location. @@ -7725,10 +7817,9 @@ class ResourceSkusResult(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: The list of skus available for the subscription. Required. + :ivar value: The ResourceSku items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :ivar next_link: The URI to fetch the next page of Resource Skus. Call ListNext() with this URI - to fetch the next page of Resource Skus. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -7743,10 +7834,9 @@ class ResourceSkusResult(_serialization.Model): def __init__(self, *, value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword value: The list of skus available for the subscription. Required. + :keyword value: The ResourceSku items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] - :keyword next_link: The URI to fetch the next page of Resource Skus. Call ListNext() with this - URI to fetch the next page of Resource Skus. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py index 8f5241fe1265..8fc0f272a8ed 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py @@ -26782,7 +26782,8 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_09_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_04_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_10_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_compute_management_client.py index 488bc07e9289..261dca95303e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_compute_management_client.py @@ -33,22 +33,21 @@ class ComputeManagementClient: """Compute Client. - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2024_03_02.operations.DisksOperations :ivar disk_accesses: DiskAccessesOperations operations :vartype disk_accesses: azure.mgmt.compute.v2024_03_02.operations.DiskAccessesOperations :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations :vartype disk_encryption_sets: azure.mgmt.compute.v2024_03_02.operations.DiskEncryptionSetsOperations + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.v2024_03_02.operations.DisksOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.v2024_03_02.operations.SnapshotsOperations :ivar disk_restore_point: DiskRestorePointOperations operations :vartype disk_restore_point: azure.mgmt.compute.v2024_03_02.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2024_03_02.operations.SnapshotsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -93,17 +92,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2024-03-02") self.disk_accesses = DiskAccessesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) self.disk_encryption_sets = DiskEncryptionSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) - self.disk_restore_point = DiskRestorePointOperations( + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2024-03-02") + self.snapshots = SnapshotsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) - self.snapshots = SnapshotsOperations( + self.disk_restore_point = DiskRestorePointOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_configuration.py index ec0e17102b9f..ba92a8559fa7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_configuration.py @@ -25,8 +25,7 @@ class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2024-03-02". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_metadata.json index 56f50a2f6fb4..12a7ad354ff6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_metadata.json +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_metadata.json @@ -24,7 +24,7 @@ }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true, "method_location": "positional" @@ -39,7 +39,7 @@ }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -105,10 +105,10 @@ "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { - "disks": "DisksOperations", "disk_accesses": "DiskAccessesOperations", "disk_encryption_sets": "DiskEncryptionSetsOperations", - "disk_restore_point": "DiskRestorePointOperations", - "snapshots": "SnapshotsOperations" + "disks": "DisksOperations", + "snapshots": "SnapshotsOperations", + "disk_restore_point": "DiskRestorePointOperations" } } diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_compute_management_client.py index 64416721f0be..8b144c2a5b9d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_compute_management_client.py @@ -33,22 +33,21 @@ class ComputeManagementClient: """Compute Client. - :ivar disks: DisksOperations operations - :vartype disks: azure.mgmt.compute.v2024_03_02.aio.operations.DisksOperations :ivar disk_accesses: DiskAccessesOperations operations :vartype disk_accesses: azure.mgmt.compute.v2024_03_02.aio.operations.DiskAccessesOperations :ivar disk_encryption_sets: DiskEncryptionSetsOperations operations :vartype disk_encryption_sets: azure.mgmt.compute.v2024_03_02.aio.operations.DiskEncryptionSetsOperations + :ivar disks: DisksOperations operations + :vartype disks: azure.mgmt.compute.v2024_03_02.aio.operations.DisksOperations + :ivar snapshots: SnapshotsOperations operations + :vartype snapshots: azure.mgmt.compute.v2024_03_02.aio.operations.SnapshotsOperations :ivar disk_restore_point: DiskRestorePointOperations operations :vartype disk_restore_point: azure.mgmt.compute.v2024_03_02.aio.operations.DiskRestorePointOperations - :ivar snapshots: SnapshotsOperations operations - :vartype snapshots: azure.mgmt.compute.v2024_03_02.aio.operations.SnapshotsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -93,17 +92,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2024-03-02") self.disk_accesses = DiskAccessesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) self.disk_encryption_sets = DiskEncryptionSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) - self.disk_restore_point = DiskRestorePointOperations( + self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize, "2024-03-02") + self.snapshots = SnapshotsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) - self.snapshots = SnapshotsOperations( + self.disk_restore_point = DiskRestorePointOperations( self._client, self._config, self._serialize, self._deserialize, "2024-03-02" ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_configuration.py index b42db3bdd5e0..66e5b9ab267b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/_configuration.py @@ -25,8 +25,7 @@ class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2024-03-02". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/__init__.py index 0e0c2d8aaf8d..e14bc6862637 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/__init__.py @@ -12,22 +12,22 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import DisksOperations # type: ignore from ._operations import DiskAccessesOperations # type: ignore from ._operations import DiskEncryptionSetsOperations # type: ignore -from ._operations import DiskRestorePointOperations # type: ignore +from ._operations import DisksOperations # type: ignore from ._operations import SnapshotsOperations # type: ignore +from ._operations import DiskRestorePointOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DisksOperations", "DiskAccessesOperations", "DiskEncryptionSetsOperations", - "DiskRestorePointOperations", + "DisksOperations", "SnapshotsOperations", + "DiskRestorePointOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/_operations.py index 7bc85f6a15f7..1cb38db07399 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/aio/operations/_operations.py @@ -81,14 +81,14 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DisksOperations: +class DiskAccessesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s - :attr:`disks` attribute. + :attr:`disk_accesses` attribute. """ models = _models @@ -101,8 +101,223 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: + """Lists all the disk access resources under a subscription. + + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_accesses_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskAccessList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: + """Lists all the disk access resources under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_accesses_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskAccessList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> _models.DiskAccess: + """Gets information about a disk access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: DiskAccess or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + + _request = build_disk_accesses_get_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + async def _create_or_update_initial( - self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccess, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -122,14 +337,14 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access else: - _json = self._serialize.body(disk, "Disk") + _json = self._serialize.body(disk_access, "DiskAccess") - _request = build_disks_create_or_update_request( + _request = build_disk_accesses_create_or_update_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -156,10 +371,15 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -167,75 +387,87 @@ async def _create_or_update_initial( async def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: _models.Disk, + disk_access_name: str, + disk_access: _models.DiskAccess, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Creates or updates a disk. + ) -> AsyncLROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] - :raises ~azure.core.exceptions.HttpResponseError: + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + disk_access_name: str, + disk_access: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Creates or updates a disk. + ) -> AsyncLROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: IO[bytes] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Creates or updates a disk. + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccess, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Is either a Disk type - or a IO[bytes] type. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Is either a DiskAccess type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -243,15 +475,15 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + disk_access_name=disk_access_name, + disk_access=disk_access, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -263,30 +495,36 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", pipeline_response.http_response) + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( + return AsyncLROPoller[_models.DiskAccess].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Disk]( + return AsyncLROPoller[_models.DiskAccess]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _update_initial( - self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -306,14 +544,14 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access else: - _json = self._serialize.body(disk, "DiskUpdate") + _json = self._serialize.body(disk_access, "DiskAccessUpdate") - _request = build_disks_update_request( + _request = build_disk_accesses_update_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -340,10 +578,15 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -351,27 +594,30 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, + disk_access_name: str, + disk_access: _models.DiskAccessUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. + ) -> AsyncLROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -379,47 +625,56 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + disk_access_name: str, + disk_access: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. + ) -> AsyncLROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_update( - self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Disk]: - """Updates (patches) a disk. + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Is either a - DiskUpdate type or a IO[bytes] type. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Is either a DiskAccessUpdate type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -427,15 +682,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + disk_access_name=disk_access_name, + disk_access=disk_access, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -447,42 +702,33 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", pipeline_response.http_response) + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Disk].from_continuation_token( + return AsyncLROPoller[_models.DiskAccess].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Disk]( + return AsyncLROPoller[_models.DiskAccess]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _models.Disk: - """Gets information about a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :return: Disk or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.Disk - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _delete_initial( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -495,11 +741,11 @@ async def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_get_request( + _request = build_disk_accesses_delete_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -507,86 +753,51 @@ async def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Disk", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - async def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a disk access resource. - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_delete_request( - resource_group_name=resource_group_name, - disk_name=disk_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -598,7 +809,7 @@ async def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -613,7 +824,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -628,20 +841,29 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Disk"]: - """Lists all the disks under a resource group. + def list_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -654,8 +876,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - _request = build_disks_list_by_resource_group_request( + _request = build_disk_accesses_list_private_endpoint_connections_request( resource_group_name=resource_group_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -681,7 +904,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -704,20 +927,25 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Disk"]: - """Lists all the disks under a subscription. + @distributed_trace_async + async def get_a_private_endpoint_connection( + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a disk access resource. - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -726,63 +954,47 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Disk"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_disk_accesses_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore - async def _grant_access_initial( + async def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -803,14 +1015,15 @@ async def _grant_access_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - _request = build_disks_grant_access_request( + _request = build_disk_accesses_update_a_private_endpoint_connection_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -837,95 +1050,121 @@ async def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_grant_access( + async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_grant_access( + async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_grant_access( + async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a + IO[bytes] type. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -933,15 +1172,16 @@ async def begin_grant_access( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._grant_access_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - grant_access_data=grant_access_data, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -953,7 +1193,7 @@ async def begin_grant_access( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessUri", pipeline_response.http_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -967,18 +1207,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.AccessUri].from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.AccessUri]( + return AsyncLROPoller[_models.PrivateEndpointConnection]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _revoke_access_initial( - self, resource_group_name: str, disk_name: str, **kwargs: Any + async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -994,9 +1234,10 @@ async def _revoke_access_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_revoke_access_request( + _request = build_disk_accesses_delete_a_private_endpoint_connection_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1012,7 +1253,7 @@ async def _revoke_access_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1020,25 +1261,33 @@ async def _revoke_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_revoke_access( - self, resource_group_name: str, disk_name: str, **kwargs: Any + async def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Revokes access to a disk. + """Deletes a private endpoint connection under a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1052,9 +1301,10 @@ async def begin_revoke_access( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._revoke_access_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1085,34 +1335,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + @distributed_trace_async + async def get_private_link_resources( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under disk access resource. -class DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _create_or_update_initial( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1121,114 +1360,408 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - _request = build_disk_accesses_create_or_update_request( + _request = build_disk_accesses_get_private_link_resources_request( resource_group_name=resource_group_name, disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a subscription. + + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_encryption_sets_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_encryption_sets_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> _models.DiskEncryptionSet: + """Gets information about a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :return: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + + _request = build_disk_encryption_sets_get_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set + else: + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + + _request = build_disk_encryption_sets_create_or_update_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1236,24 +1769,27 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1261,15 +1797,15 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + disk_encryption_set_name=disk_encryption_set_name, + disk_encryption_set=disk_encryption_set, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1281,33 +1817,35 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskAccess].from_continuation_token( + return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskAccess]( + return AsyncLROPoller[_models.DiskEncryptionSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _update_initial( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1328,14 +1866,14 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") - _request = build_disk_accesses_update_request( + _request = build_disk_encryption_sets_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1362,10 +1900,15 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1373,29 +1916,31 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSetUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1403,29 +1948,31 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type disk_access: IO[bytes] + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1433,24 +1980,28 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Is either a DiskAccessUpdate type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either DiskAccess or the result of + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Is either a DiskEncryptionSetUpdate type or a IO[bytes] type. + Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1458,15 +2009,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + disk_encryption_set_name=disk_encryption_set_name, + disk_encryption_set=disk_encryption_set, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1478,86 +2029,32 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskAccess].from_continuation_token( + return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskAccess]( + return AsyncLROPoller[_models.DiskEncryptionSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> _models.DiskAccess: - """Gets information about a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: DiskAccess or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - async def _delete_initial( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1573,9 +2070,9 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_accesses_delete_request( + _request = build_disk_encryption_sets_delete_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1599,25 +2096,31 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes a disk access resource. + """Deletes a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1633,7 +2136,7 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1648,7 +2151,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -1663,21 +2168,27 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: - """Lists all the disk access resources under a resource group. + def list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> AsyncIterable[str]: + """Lists all resources that are encrypted with this disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceUriList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1690,8 +2201,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - _request = build_disk_accesses_list_by_resource_group_request( + _request = build_disk_encryption_sets_list_associated_resources_request( resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1717,7 +2229,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskAccessList", pipeline_response) + deserialized = self._deserialize("ResourceUriList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1740,20 +2252,117 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: - """Lists all the disk access resources under a subscription. + def list(self, **kwargs: Any) -> AsyncIterable["_models.Disk"]: + """Lists all the disks under a subscription. - :return: An iterator like instance of either DiskAccess or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disks_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Disk"]: + """Lists all the disks under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1766,7 +2375,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskAccess"]: def prepare_request(next_link=None): if not next_link: - _request = build_disk_accesses_list_request( + _request = build_disks_list_by_resource_group_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1792,7 +2402,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskAccessList", pipeline_response) + deserialized = self._deserialize("DiskList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1816,19 +2426,18 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_private_link_resources( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources possible under disk access resource. + async def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _models.Disk: + """Gets information about a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateLinkResourceListResult + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :return: Disk or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.Disk :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1843,11 +2452,11 @@ async def get_private_link_resources( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - _request = build_disk_accesses_get_private_link_resources_request( + _request = build_disks_get_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1866,20 +2475,15 @@ async def get_private_link_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) + deserialized = self._deserialize("Disk", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any + async def _create_or_update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1899,15 +2503,14 @@ async def _update_a_private_endpoint_connection_initial( # pylint: disable=name content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IOBase, bytes)): - _content = private_endpoint_connection + if isinstance(disk, (IOBase, bytes)): + _content = disk else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + _json = self._serialize.body(disk, "Disk") - _request = build_disk_accesses_update_a_private_endpoint_connection_request( + _request = build_disks_create_or_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1934,113 +2537,94 @@ async def _update_a_private_endpoint_connection_initial( # pylint: disable=name map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long + async def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, + disk_name: str, + disk: _models.Disk, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + ) -> AsyncLROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Required. - :type private_endpoint_connection: - ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long + async def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO[bytes], + disk_name: str, + disk: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + ) -> AsyncLROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Required. - :type private_endpoint_connection: IO[bytes] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Required. + :type disk: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + async def begin_create_or_update( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a - IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Is either a Disk type + or a IO[bytes] type. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2048,16 +2632,15 @@ async def begin_update_a_private_endpoint_connection( # pylint: disable=name-to api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, + disk_name=disk_name, + disk=disk, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2069,91 +2652,32 @@ async def begin_update_a_private_endpoint_connection( # pylint: disable=name-to kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + deserialized = self._deserialize("Disk", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - return deserialized # type: ignore + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Disk].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Disk]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + async def _update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2163,18 +2687,29 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_accesses_delete_a_private_endpoint_connection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "DiskUpdate") + + _request = build_disks_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2188,7 +2723,7 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2196,186 +2731,146 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: _models.DiskUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Updates (patches) a disk. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Updates (patches) a disk. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Required. + :type disk: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection under a disk access resource. + async def begin_update( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Updates (patches) a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Is either a + DiskUpdate type or a IO[bytes] type. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_a_private_endpoint_connection_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, + disk_name=disk_name, + disk=disk, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """List information about private endpoint connections under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Disk].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Disk]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _create_or_update_initial( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + async def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2384,29 +2879,17 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( + _request = build_disks_delete_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -2420,7 +2903,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2428,117 +2911,46 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + async def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._delete_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + disk_name=disk_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -2547,34 +2959,32 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskEncryptionSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _update_initial( + async def _grant_access_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -2595,14 +3005,14 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set + if isinstance(grant_access_data, (IOBase, bytes)): + _content = grant_access_data else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_disk_encryption_sets_update_request( + _request = build_disks_grant_access_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2629,100 +3039,103 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSetUpdate, + disk_name: str, + grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + disk_name: str, + grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Required. + :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Is either a DiskEncryptionSetUpdate type or a IO[bytes] type. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either DiskEncryptionSet or the result of + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Is either a GrantAccessData type or a IO[bytes] type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2730,15 +3143,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._grant_access_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + disk_name=disk_name, + grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2750,88 +3163,32 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + deserialized = self._deserialize("AccessUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DiskEncryptionSet].from_continuation_token( + return AsyncLROPoller[_models.AccessUri].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DiskEncryptionSet]( + return AsyncLROPoller[_models.AccessUri]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> _models.DiskEncryptionSet: - """Gets information about a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) - - _request = build_disk_encryption_sets_get_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + async def _revoke_access_initial( + self, resource_group_name: str, disk_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2847,9 +3204,9 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_encryption_sets_delete_request( + _request = build_disks_revoke_access_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2865,7 +3222,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2873,25 +3230,31 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + async def begin_revoke_access( + self, resource_group_name: str, disk_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes a disk encryption set. + """Revokes access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2905,9 +3268,9 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._revoke_access_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2922,7 +3285,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -2936,100 +3301,41 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ - return pipeline_response + models = _models - return AsyncItemPaged(get_next, extract_data) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a subscription. + def list(self, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: + """Lists snapshots under a subscription. - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :return: An iterator like instance of either Snapshot or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3042,7 +3348,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DiskEncryptionSet"]: def prepare_request(next_link=None): if not next_link: - _request = build_disk_encryption_sets_list_request( + _request = build_snapshots_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3068,7 +3374,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + deserialized = self._deserialize("SnapshotList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -3092,26 +3398,22 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable[str]: - """Lists all resources that are encrypted with this disk encryption set. + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: + """Lists snapshots under a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.ResourceUriList] = kwargs.pop("cls", None) + cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3124,9 +3426,8 @@ def list_associated_resources( def prepare_request(next_link=None): if not next_link: - _request = build_disk_encryption_sets_list_associated_resources_request( + _request = build_snapshots_list_by_resource_group_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3152,7 +3453,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUriList", pipeline_response) + deserialized = self._deserialize("SnapshotList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -3175,50 +3476,19 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace_async - async def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - **kwargs: Any - ) -> _models.DiskRestorePoint: - """Get disk restorePoint resource. + async def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: + """Gets information about a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3233,13 +3503,11 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - _request = build_disk_restore_point_get_request( + _request = build_snapshots_get_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3258,109 +3526,15 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DiskRestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_restore_point( - self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePoint"]: - """Lists diskRestorePoints under a vmRestorePoint. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any + async def _create_or_update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3380,16 +3554,14 @@ async def _grant_access_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + _json = self._serialize.body(snapshot, "Snapshot") - _request = build_disk_restore_point_grant_access_request( + _request = build_snapshots_create_or_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3416,113 +3588,97 @@ async def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_grant_access( + async def begin_create_or_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: _models.GrantAccessData, + snapshot_name: str, + snapshot: _models.Snapshot, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_grant_access( + async def begin_create_or_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: IO[bytes], + snapshot_name: str, + snapshot: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_grant_access( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AccessUri or the result of + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Is either a + Snapshot type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3530,17 +3686,15 @@ async def begin_grant_access( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._grant_access_initial( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, - grant_access_data=grant_access_data, + snapshot_name=snapshot_name, + snapshot=snapshot, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3552,7 +3706,7 @@ async def begin_grant_access( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessUri", pipeline_response.http_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -3566,22 +3720,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.AccessUri].from_continuation_token( + return AsyncLROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.AccessUri]( + return AsyncLROPoller[_models.Snapshot]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _revoke_access_initial( + async def _update_initial( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3592,19 +3745,29 @@ async def _revoke_access_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_restore_point_revoke_access_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "SnapshotUpdate") + + _request = build_snapshots_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3626,53 +3789,121 @@ async def _revoke_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: _models.SnapshotUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_revoke_access( + async def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revokes access to a diskRestorePoint. + ) -> AsyncLROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is + either a SnapshotUpdate type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._revoke_access_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, + snapshot=snapshot, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3681,9 +3912,11 @@ async def begin_revoke_access( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( @@ -3694,37 +3927,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return AsyncLROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _create_or_update_initial( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + async def _delete_initial( + self, resource_group_name: str, snapshot_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3734,29 +3948,17 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( + _request = build_snapshots_delete_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3770,115 +3972,54 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + async def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Is either a - Snapshot type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._delete_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, - snapshot=snapshot, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3887,34 +4028,32 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Snapshot].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Snapshot]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _update_initial( + async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3935,12 +4074,12 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(grant_access_data, (IOBase, bytes)): + _content = grant_access_data else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") + _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_snapshots_update_request( + _request = build_snapshots_grant_access_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -3969,95 +4108,103 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: _models.SnapshotUpdate, + grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: IO[bytes], + grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Snapshot or the result of + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Is either a GrantAccessData type or a IO[bytes] type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] + :return: An instance of AsyncLROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4065,15 +4212,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._grant_access_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, - snapshot=snapshot, + grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4085,85 +4232,31 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + deserialized = self._deserialize("AccessUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Snapshot].from_continuation_token( + return AsyncLROPoller[_models.AccessUri].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Snapshot]( + return AsyncLROPoller[_models.AccessUri]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :return: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.Snapshot - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - - _request = build_snapshots_get_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( + async def _revoke_access_initial( self, resource_group_name: str, snapshot_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -4180,7 +4273,7 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_delete_request( + _request = build_snapshots_revoke_access_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -4198,7 +4291,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -4206,18 +4299,26 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a snapshot. + async def begin_revoke_access( + self, resource_group_name: str, snapshot_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Revokes access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. @@ -4236,7 +4337,7 @@ async def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwa lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._revoke_access_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, @@ -4253,7 +4354,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -4267,22 +4370,52 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: - """Lists snapshots under a resource group. + def list_by_restore_point( + self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DiskRestorePoint"]: + """Lists diskRestorePoints under a vmRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Snapshot or the result of cls(response) + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskRestorePointListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4295,8 +4428,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - _request = build_snapshots_list_by_resource_group_request( + _request = build_disk_restore_point_list_by_restore_point_request( resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4322,7 +4457,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) + deserialized = self._deserialize("DiskRestorePointListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4345,21 +4480,32 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: - """Lists snapshots under a subscription. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> _models.DiskRestorePoint: + """Get disk restorePoint resource. - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4368,62 +4514,48 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Snapshot"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_snapshots_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_disk_restore_point_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("DiskRestorePoint", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore async def _grant_access_initial( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -4450,9 +4582,11 @@ async def _grant_access_initial( else: _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_snapshots_grant_access_request( + _request = build_disk_restore_point_grant_access_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4479,10 +4613,15 @@ async def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -4490,21 +4629,28 @@ async def _grant_access_initial( async def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Required. :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -4520,21 +4666,28 @@ async def begin_grant_access( async def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Required. :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -4550,19 +4703,26 @@ async def begin_grant_access( async def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Is either a GrantAccessData type or a IO[bytes] type. Required. :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] :return: An instance of AsyncLROPoller that returns either AccessUri or the result of @@ -4582,7 +4742,9 @@ async def begin_grant_access( if cont_token is None: raw_result = await self._grant_access_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, @@ -4620,7 +4782,12 @@ def get_long_running_output(pipeline_response): ) async def _revoke_access_initial( - self, resource_group_name: str, snapshot_name: str, **kwargs: Any + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4636,9 +4803,11 @@ async def _revoke_access_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_revoke_access_request( + _request = build_disk_restore_point_revoke_access_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4662,25 +4831,40 @@ async def _revoke_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_revoke_access( - self, resource_group_name: str, snapshot_name: str, **kwargs: Any + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any ) -> AsyncLROPoller[None]: - """Revokes access to a snapshot. + """Revokes access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -4696,7 +4880,9 @@ async def begin_revoke_access( if cont_token is None: raw_result = await self._revoke_access_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/__init__.py index 087321a1aa15..0b2e53c22a01 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/__init__.py @@ -27,8 +27,9 @@ DiskEncryptionSetList, DiskEncryptionSetUpdate, DiskList, + DiskPurchasePlan, DiskRestorePoint, - DiskRestorePointList, + DiskRestorePointListResult, DiskSecurityProfile, DiskSku, DiskUpdate, @@ -50,9 +51,9 @@ PrivateLinkResourceListResult, PrivateLinkServiceConnectionState, PropertyUpdatesInProgress, - ProxyOnlyResource, - PurchasePlan, + ProxyResource, Resource, + ResourceAutoGenerated, ResourceUriList, ResourceWithOptionalLocation, ShareInfoElement, @@ -65,13 +66,17 @@ SubResourceReadOnly, SupportedCapabilities, SystemData, + SystemDataAutoGenerated, + TrackedResource, UserAssignedIdentitiesValue, + UserAssignedIdentitiesValueAutoGenerated, ) from ._compute_management_client_enums import ( # type: ignore AccessLevel, Architecture, CopyCompletionErrorReason, + CreatedByType, DataAccessAuthMode, DiskCreateOption, DiskEncryptionSetIdentityType, @@ -109,8 +114,9 @@ "DiskEncryptionSetList", "DiskEncryptionSetUpdate", "DiskList", + "DiskPurchasePlan", "DiskRestorePoint", - "DiskRestorePointList", + "DiskRestorePointListResult", "DiskSecurityProfile", "DiskSku", "DiskUpdate", @@ -132,9 +138,9 @@ "PrivateLinkResourceListResult", "PrivateLinkServiceConnectionState", "PropertyUpdatesInProgress", - "ProxyOnlyResource", - "PurchasePlan", + "ProxyResource", "Resource", + "ResourceAutoGenerated", "ResourceUriList", "ResourceWithOptionalLocation", "ShareInfoElement", @@ -147,10 +153,14 @@ "SubResourceReadOnly", "SupportedCapabilities", "SystemData", + "SystemDataAutoGenerated", + "TrackedResource", "UserAssignedIdentitiesValue", + "UserAssignedIdentitiesValueAutoGenerated", "AccessLevel", "Architecture", "CopyCompletionErrorReason", + "CreatedByType", "DataAccessAuthMode", "DiskCreateOption", "DiskEncryptionSetIdentityType", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_compute_management_client_enums.py index 4a70d0b63b49..d2939b5451cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_compute_management_client_enums.py @@ -11,7 +11,7 @@ class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessLevel.""" + """The Access Level, accepted values include None, Read, Write.""" NONE = "None" READ = "Read" @@ -35,6 +35,15 @@ class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): created via CopyStart operation was in progress.""" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Additional authentication requirements when exporting or uploading to a disk or snapshot.""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_models_py3.py index 22fde77e943d..7128de1e2bb6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/models/_models_py3.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -321,28 +322,76 @@ def __init__( class Resource(_serialization.Model): - """The Resource model definition. + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -350,42 +399,45 @@ class Resource(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location self.tags = tags + self.location = location -class Disk(Resource): +class Disk(TrackedResource): """Disk resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar managed_by: A relative URI containing the ID of the VM that has the disk attached. :vartype managed_by: str :ivar managed_by_extended: List of relative URIs containing the IDs of the VMs that have the @@ -410,7 +462,7 @@ class Disk(Resource): :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer}. - :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :ivar supported_capabilities: List of supported capabilities for the image from which the OS disk was created. :vartype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -507,6 +559,7 @@ class Disk(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "managed_by": {"readonly": True}, "managed_by_extended": {"readonly": True}, @@ -525,8 +578,9 @@ class Disk(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "managed_by": {"key": "managedBy", "type": "str"}, "managed_by_extended": {"key": "managedByExtended", "type": "[str]"}, "sku": {"key": "sku", "type": "DiskSku"}, @@ -535,7 +589,7 @@ class Disk(Resource): "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, "os_type": {"key": "properties.osType", "type": "str"}, "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "PurchasePlan"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "DiskPurchasePlan"}, "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, "creation_data": {"key": "properties.creationData", "type": "CreationData"}, "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, @@ -582,7 +636,7 @@ def __init__( # pylint: disable=too-many-locals extended_location: Optional["_models.ExtendedLocation"] = None, os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, + purchase_plan: Optional["_models.DiskPurchasePlan"] = None, supported_capabilities: Optional["_models.SupportedCapabilities"] = None, creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, @@ -606,10 +660,10 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. :paramtype sku: ~azure.mgmt.compute.v2024_03_02.models.DiskSku @@ -626,7 +680,7 @@ def __init__( # pylint: disable=too-many-locals :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer}. - :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :keyword supported_capabilities: List of supported capabilities for the image from which the OS disk was created. :paramtype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -698,7 +752,7 @@ def __init__( # pylint: disable=too-many-locals the virtual machine. :paramtype optimized_for_frequent_attach: bool """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.managed_by = None self.managed_by_extended = None self.sku = sku @@ -738,23 +792,28 @@ def __init__( # pylint: disable=too-many-locals self.last_ownership_update_time = None -class DiskAccess(Resource): +class DiskAccess(TrackedResource): """disk access resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar extended_location: The extended location where the disk access will be created. Extended location cannot be changed. :vartype extended_location: ~azure.mgmt.compute.v2024_03_02.models.ExtendedLocation @@ -772,6 +831,7 @@ class DiskAccess(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "private_endpoint_connections": {"readonly": True}, "provisioning_state": {"readonly": True}, @@ -782,8 +842,9 @@ class DiskAccess(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, "private_endpoint_connections": { "key": "properties.privateEndpointConnections", @@ -802,15 +863,15 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword extended_location: The extended location where the disk access will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2024_03_02.models.ExtendedLocation """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.extended_location = extended_location self.private_endpoint_connections = None self.provisioning_state = None @@ -822,10 +883,9 @@ class DiskAccessList(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: A list of disk access resources. Required. + :ivar value: The DiskAccess items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] - :ivar next_link: The uri to fetch the next page of disk access resources. Call ListNext() with - this to fetch the next page of disk access resources. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -840,10 +900,9 @@ class DiskAccessList(_serialization.Model): def __init__(self, *, value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword value: A list of disk access resources. Required. + :keyword value: The DiskAccess items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] - :keyword next_link: The uri to fetch the next page of disk access resources. Call ListNext() - with this to fetch the next page of disk access resources. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -871,23 +930,28 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class DiskEncryptionSet(Resource): +class DiskEncryptionSet(TrackedResource): """disk encryption set resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2024_03_02.models.EncryptionSetIdentity @@ -922,6 +986,7 @@ class DiskEncryptionSet(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "previous_keys": {"readonly": True}, "provisioning_state": {"readonly": True}, @@ -933,8 +998,9 @@ class DiskEncryptionSet(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "identity": {"key": "identity", "type": "EncryptionSetIdentity"}, "encryption_type": {"key": "properties.encryptionType", "type": "str"}, "active_key": {"key": "properties.activeKey", "type": "KeyForDiskEncryptionSet"}, @@ -962,10 +1028,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2024_03_02.models.EncryptionSetIdentity @@ -982,7 +1048,7 @@ def __init__( different tenant. Setting the value to 'None' will clear the property. :paramtype federated_client_id: str """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.encryption_type = encryption_type self.active_key = active_key @@ -999,10 +1065,9 @@ class DiskEncryptionSetList(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: A list of disk encryption sets. Required. + :ivar value: The DiskEncryptionSet items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :ivar next_link: The uri to fetch the next page of disk encryption sets. Call ListNext() with - this to fetch the next page of disk encryption sets. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -1019,10 +1084,9 @@ def __init__( self, *, value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: A list of disk encryption sets. Required. + :keyword value: The DiskEncryptionSet items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :keyword next_link: The uri to fetch the next page of disk encryption sets. Call ListNext() - with this to fetch the next page of disk encryption sets. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1110,10 +1174,9 @@ class DiskList(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: A list of disks. Required. + :ivar value: The Disk items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.Disk] - :ivar next_link: The uri to fetch the next page of disks. Call ListNext() with this to fetch - the next page of disks. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -1128,10 +1191,9 @@ class DiskList(_serialization.Model): def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword value: A list of disks. Required. + :keyword value: The Disk items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.Disk] - :keyword next_link: The uri to fetch the next page of disks. Call ListNext() with this to fetch - the next page of disks. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1139,50 +1201,92 @@ def __init__(self, *, value: List["_models.Disk"], next_link: Optional[str] = No self.next_link = next_link -class ProxyOnlyResource(_serialization.Model): - """The ProxyOnly Resource model definition. +class DiskPurchasePlan(_serialization.Model): + """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. + :ivar name: The plan ID. Required. :vartype name: str - :ivar type: Resource type. - :vartype type: str + :ivar publisher: The publisher ID. Required. + :vartype publisher: str + :ivar product: Specifies the product of the image from the marketplace. This is the same value + as Offer under the imageReference element. Required. + :vartype product: str + :ivar promotion_code: The Offer Promotion Code. + :vartype promotion_code: str """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, *, name: str, publisher: str, product: str, promotion_code: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword name: The plan ID. Required. + :paramtype name: str + :keyword publisher: The publisher ID. Required. + :paramtype publisher: str + :keyword product: Specifies the product of the image from the marketplace. This is the same + value as Offer under the imageReference element. Required. + :paramtype product: str + :keyword promotion_code: The Offer Promotion Code. + :paramtype promotion_code: str + """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. -class DiskRestorePoint(ProxyOnlyResource): + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData + """ + + +class DiskRestorePoint(ProxyResource): """Properties of disk restore point. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar time_created: The timestamp of restorePoint creation. :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk or source disk restore point. @@ -1194,7 +1298,7 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2024_03_02.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. - :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :ivar supported_capabilities: List of supported capabilities for the image from which the OS disk was created. :vartype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -1237,6 +1341,7 @@ class DiskRestorePoint(ProxyOnlyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "time_created": {"readonly": True}, "source_resource_id": {"readonly": True}, "os_type": {"readonly": True}, @@ -1252,11 +1357,12 @@ class DiskRestorePoint(ProxyOnlyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, "source_resource_id": {"key": "properties.sourceResourceId", "type": "str"}, "os_type": {"key": "properties.osType", "type": "str"}, "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "PurchasePlan"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "DiskPurchasePlan"}, "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, "family_id": {"key": "properties.familyId", "type": "str"}, "source_unique_id": {"key": "properties.sourceUniqueId", "type": "str"}, @@ -1276,7 +1382,7 @@ def __init__( self, *, hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, + purchase_plan: Optional["_models.DiskPurchasePlan"] = None, supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, @@ -1292,7 +1398,7 @@ def __init__( :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2024_03_02.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. - :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :keyword supported_capabilities: List of supported capabilities for the image from which the OS disk was created. :paramtype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -1336,15 +1442,14 @@ def __init__( self.logical_sector_size = None -class DiskRestorePointList(_serialization.Model): - """The List Disk Restore Points operation response. +class DiskRestorePointListResult(_serialization.Model): + """Paged collection of DiskRestorePoint items. All required parameters must be populated in order to send to server. - :ivar value: A list of disk restore points. Required. + :ivar value: The DiskRestorePoint items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] - :ivar next_link: The uri to fetch the next page of disk restore points. Call ListNext() with - this to fetch the next page of disk restore points. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -1361,10 +1466,9 @@ def __init__( self, *, value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: A list of disk restore points. Required. + :keyword value: The DiskRestorePoint items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] - :keyword next_link: The uri to fetch the next page of disk restore points. Call ListNext() with - this to fetch the next page of disk restore points. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1500,7 +1604,7 @@ class DiskUpdate(_serialization.Model): target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. :vartype bursting_enabled: bool :ivar purchase_plan: Purchase plan information to be added on the OS disk. - :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :ivar supported_capabilities: List of supported capabilities to be added on the OS disk. :vartype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities :ivar property_updates_in_progress: Properties of the disk for which update is pending. @@ -1547,7 +1651,7 @@ class DiskUpdate(_serialization.Model): "disk_access_id": {"key": "properties.diskAccessId", "type": "str"}, "tier": {"key": "properties.tier", "type": "str"}, "bursting_enabled": {"key": "properties.burstingEnabled", "type": "bool"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "PurchasePlan"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "DiskPurchasePlan"}, "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, "property_updates_in_progress": { "key": "properties.propertyUpdatesInProgress", @@ -1577,7 +1681,7 @@ def __init__( disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, + purchase_plan: Optional["_models.DiskPurchasePlan"] = None, supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, @@ -1637,7 +1741,7 @@ def __init__( target of the disk. Bursting is disabled by default. Does not apply to Ultra disks. :paramtype bursting_enabled: bool :keyword purchase_plan: Purchase plan information to be added on the OS disk. - :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :keyword supported_capabilities: List of supported capabilities to be added on the OS disk. :paramtype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. @@ -1916,7 +2020,8 @@ class GrantAccessData(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar access: Required. Known values are: "None", "Read", and "Write". + :ivar access: The Access Level, accepted values include None, Read, Write. Required. Known + values are: "None", "Read", and "Write". :vartype access: str or ~azure.mgmt.compute.v2024_03_02.models.AccessLevel :ivar duration_in_seconds: Time duration in seconds until the SAS access expires. Required. :vartype duration_in_seconds: int @@ -1950,7 +2055,8 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword access: Required. Known values are: "None", "Read", and "Write". + :keyword access: The Access Level, accepted values include None, Read, Write. Required. Known + values are: "None", "Read", and "Write". :paramtype access: str or ~azure.mgmt.compute.v2024_03_02.models.AccessLevel :keyword duration_in_seconds: Time duration in seconds until the SAS access expires. Required. :paramtype duration_in_seconds: int @@ -2178,17 +2284,22 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class PrivateEndpointConnection(_serialization.Model): +class PrivateEndpointConnection(ProxyResource): """The Private Endpoint Connection resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: private endpoint connection Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: private endpoint connection name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: private endpoint connection type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar private_endpoint: The resource of private end point. :vartype private_endpoint: ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpoint :ivar private_link_service_connection_state: A collection of information about the state of the @@ -2205,6 +2316,7 @@ class PrivateEndpointConnection(_serialization.Model): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "private_endpoint": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -2213,6 +2325,7 @@ class PrivateEndpointConnection(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, "private_link_service_connection_state": { "key": "properties.privateLinkServiceConnectionState", @@ -2234,9 +2347,6 @@ def __init__( ~azure.mgmt.compute.v2024_03_02.models.PrivateLinkServiceConnectionState """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None self.private_endpoint = None self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None @@ -2245,30 +2355,30 @@ def __init__( class PrivateEndpointConnectionListResult(_serialization.Model): """A list of private link resources. - :ivar value: Array of private endpoint connections. + All required parameters must be populated in order to send to server. + + :ivar value: The PrivateEndpointConnection items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] - :ivar next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to - fetch the next page of snapshots. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.PrivateEndpointConnection"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Array of private endpoint connections. + :keyword value: The PrivateEndpointConnection items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] - :keyword next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to - fetch the next page of snapshots. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -2414,54 +2524,53 @@ def __init__(self, *, target_tier: Optional[str] = None, **kwargs: Any) -> None: self.target_tier = target_tier -class PurchasePlan(_serialization.Model): - """Used for establishing the purchase context of any 3rd Party artifact through MarketPlace. +class ResourceAutoGenerated(_serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar name: The plan ID. Required. + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. :vartype name: str - :ivar publisher: The publisher ID. Required. - :vartype publisher: str - :ivar product: Specifies the product of the image from the marketplace. This is the same value - as Offer under the imageReference element. Required. - :vartype product: str - :ivar promotion_code: The Offer Promotion Code. - :vartype promotion_code: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ _validation = { - "name": {"required": True}, - "publisher": {"required": True}, - "product": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "publisher": {"key": "publisher", "type": "str"}, - "product": {"key": "product", "type": "str"}, - "promotion_code": {"key": "promotionCode", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, *, name: str, publisher: str, product: str, promotion_code: Optional[str] = None, **kwargs: Any - ) -> None: + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword name: The plan ID. Required. - :paramtype name: str - :keyword publisher: The publisher ID. Required. - :paramtype publisher: str - :keyword product: Specifies the product of the image from the marketplace. This is the same - value as Offer under the imageReference element. Required. - :paramtype product: str - :keyword promotion_code: The Offer Promotion Code. - :paramtype promotion_code: str + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.name = name - self.publisher = publisher - self.product = product - self.promotion_code = promotion_code + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags class ResourceUriList(_serialization.Model): @@ -2569,23 +2678,28 @@ def __init__(self, **kwargs: Any) -> None: self.vm_uri = None -class Snapshot(Resource): +class Snapshot(TrackedResource): """Snapshot resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_03_02.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar managed_by: Unused. Always Null. :vartype managed_by: str :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. This is @@ -2604,7 +2718,7 @@ class Snapshot(Resource): :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2024_03_02.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. - :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :vartype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :ivar supported_capabilities: List of supported capabilities for the image from which the source disk from the snapshot was originally created. :vartype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -2669,6 +2783,7 @@ class Snapshot(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "managed_by": {"readonly": True}, "time_created": {"readonly": True}, @@ -2683,15 +2798,16 @@ class Snapshot(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "managed_by": {"key": "managedBy", "type": "str"}, "sku": {"key": "sku", "type": "SnapshotSku"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, "time_created": {"key": "properties.timeCreated", "type": "iso-8601"}, "os_type": {"key": "properties.osType", "type": "str"}, "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "purchase_plan": {"key": "properties.purchasePlan", "type": "PurchasePlan"}, + "purchase_plan": {"key": "properties.purchasePlan", "type": "DiskPurchasePlan"}, "supported_capabilities": {"key": "properties.supportedCapabilities", "type": "SupportedCapabilities"}, "creation_data": {"key": "properties.creationData", "type": "CreationData"}, "disk_size_gb": {"key": "properties.diskSizeGB", "type": "int"}, @@ -2725,7 +2841,7 @@ def __init__( # pylint: disable=too-many-locals extended_location: Optional["_models.ExtendedLocation"] = None, os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - purchase_plan: Optional["_models.PurchasePlan"] = None, + purchase_plan: Optional["_models.DiskPurchasePlan"] = None, supported_capabilities: Optional["_models.SupportedCapabilities"] = None, creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, @@ -2743,10 +2859,10 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. This is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. @@ -2761,7 +2877,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2024_03_02.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. - :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.PurchasePlan + :paramtype purchase_plan: ~azure.mgmt.compute.v2024_03_02.models.DiskPurchasePlan :keyword supported_capabilities: List of supported capabilities for the image from which the source disk from the snapshot was originally created. :paramtype supported_capabilities: ~azure.mgmt.compute.v2024_03_02.models.SupportedCapabilities @@ -2809,7 +2925,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2024_03_02.models.DataAccessAuthMode """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.managed_by = None self.sku = sku self.extended_location = extended_location @@ -2845,8 +2961,7 @@ class SnapshotList(_serialization.Model): :ivar value: A list of snapshots. Required. :vartype value: list[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :ivar next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to - fetch the next page of snapshots. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -2863,8 +2978,7 @@ def __init__(self, *, value: List["_models.Snapshot"], next_link: Optional[str] """ :keyword value: A list of snapshots. Required. :paramtype value: list[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :keyword next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to - fetch the next page of snapshots. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -3153,6 +3267,70 @@ def __init__( class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.compute.v2024_03_02.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.compute.v2024_03_02.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.compute.v2024_03_02.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.compute.v2024_03_02.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class SystemDataAutoGenerated(_serialization.Model): """The system meta data relating to this resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -3208,3 +3386,31 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.principal_id = None self.client_id = None + + +class UserAssignedIdentitiesValueAutoGenerated(_serialization.Model): + """UserAssignedIdentitiesValueAutoGenerated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/__init__.py index 0e0c2d8aaf8d..e14bc6862637 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/__init__.py @@ -12,22 +12,22 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import DisksOperations # type: ignore from ._operations import DiskAccessesOperations # type: ignore from ._operations import DiskEncryptionSetsOperations # type: ignore -from ._operations import DiskRestorePointOperations # type: ignore +from ._operations import DisksOperations # type: ignore from ._operations import SnapshotsOperations # type: ignore +from ._operations import DiskRestorePointOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DisksOperations", "DiskAccessesOperations", "DiskEncryptionSetsOperations", - "DiskRestorePointOperations", + "DisksOperations", "SnapshotsOperations", + "DiskRestorePointOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/_operations.py index edb0607d7879..1c614ac3ff1a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_03_02/operations/_operations.py @@ -44,25 +44,17 @@ _SERIALIZER.client_side_validation = False -def build_disks_create_or_update_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_disk_accesses_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -71,32 +63,30 @@ def build_disks_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_update_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -105,15 +95,13 @@ def build_disks_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_get_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_get_request( + resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -124,12 +112,14 @@ def build_disks_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -143,21 +133,27 @@ def build_disks_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_delete_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -165,26 +161,35 @@ def build_disks_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any + +def build_disk_accesses_update_request( + resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -193,12 +198,16 @@ def build_disks_list_by_resource_group_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_disk_accesses_delete_request( + resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -206,9 +215,16 @@ def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -219,28 +235,29 @@ def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_grant_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_list_private_endpoint_connections_request( # pylint: disable=name-too-long + resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -249,28 +266,38 @@ def build_disks_grant_access_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disks_revoke_access_request( - resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_get_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -278,11 +305,18 @@ def build_disks_revoke_access_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any + +def build_disk_accesses_update_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -294,12 +328,17 @@ def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-lo # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -315,25 +354,33 @@ def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-lo return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_update_request( - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any +def build_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + disk_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -342,14 +389,12 @@ def build_disk_accesses_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_get_request( +def build_disk_accesses_get_private_link_resources_request( # pylint: disable=name-too-long resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -361,11 +406,13 @@ def build_disk_accesses_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privatelinkresources", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), } @@ -380,9 +427,7 @@ def build_disk_accesses_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_delete_request( - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_disk_encryption_sets_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -390,14 +435,9 @@ def build_disk_accesses_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -408,10 +448,10 @@ def build_disk_accesses_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_list_by_resource_group_request( # pylint: disable=name-too-long +def build_disk_encryption_sets_list_by_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -423,11 +463,13 @@ def build_disk_accesses_list_by_resource_group_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -441,7 +483,9 @@ def build_disk_accesses_list_by_resource_group_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_disk_encryption_sets_get_request( + resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -449,9 +493,16 @@ def build_disk_accesses_list_request(subscription_id: str, **kwargs: Any) -> Htt accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -465,24 +516,27 @@ def build_disk_accesses_list_request(subscription_id: str, **kwargs: Any) -> Htt return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_get_private_link_resources_request( # pylint: disable=name-too-long - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any +def build_disk_encryption_sets_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -491,17 +545,15 @@ def build_disk_accesses_get_private_link_resources_request( # pylint: disable=n _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_update_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any +def build_disk_encryption_sets_update_request( # pylint: disable=name-too-long + resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -513,15 +565,14 @@ def build_disk_accesses_update_a_private_endpoint_connection_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -534,15 +585,11 @@ def build_disk_accesses_update_a_private_endpoint_connection_request( # pylint: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_get_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any +def build_disk_encryption_sets_delete_request( # pylint: disable=name-too-long + resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -553,15 +600,14 @@ def build_disk_accesses_get_a_private_endpoint_connection_request( # pylint: di # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -572,15 +618,11 @@ def build_disk_accesses_get_a_private_endpoint_connection_request( # pylint: di # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any +def build_disk_encryption_sets_list_associated_resources_request( # pylint: disable=name-too-long + resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -591,15 +633,14 @@ def build_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -610,12 +651,10 @@ def build_disk_accesses_delete_a_private_endpoint_connection_request( # pylint: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_accesses_list_private_endpoint_connections_request( # pylint: disable=name-too-long - resource_group_name: str, disk_access_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_disks_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -623,14 +662,9 @@ def build_disk_accesses_list_private_endpoint_connections_request( # pylint: di accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskAccessName": _SERIALIZER.url("disk_access_name", disk_access_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -644,25 +678,25 @@ def build_disk_accesses_list_private_endpoint_connections_request( # pylint: di return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_disks_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -671,32 +705,31 @@ def build_disk_encryption_sets_create_or_update_request( # pylint: disable=name _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_update_request( # pylint: disable=name-too-long - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_disks_get_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -705,31 +738,32 @@ def build_disk_encryption_sets_update_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_get_request( - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_disks_create_or_update_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -738,29 +772,34 @@ def build_disk_encryption_sets_get_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_disks_update_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -769,13 +808,15 @@ def build_disk_encryption_sets_delete_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_disks_delete_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -786,11 +827,14 @@ def build_disk_encryption_sets_list_by_resource_group_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -801,20 +845,30 @@ def build_disk_encryption_sets_list_by_resource_group_request( # pylint: disabl # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_disks_grant_access_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -823,13 +877,15 @@ def build_disk_encryption_sets_list_request(subscription_id: str, **kwargs: Any) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_encryption_sets_list_associated_resources_request( # pylint: disable=name-too-long - resource_group_name: str, disk_encryption_set_name: str, subscription_id: str, **kwargs: Any +def build_disks_revoke_access_request( + resource_group_name: str, disk_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -840,12 +896,14 @@ def build_disk_encryption_sets_list_associated_resources_request( # pylint: dis # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "diskEncryptionSetName": _SERIALIZER.url("disk_encryption_set_name", disk_encryption_set_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diskName": _SERIALIZER.url("disk_name", disk_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -856,17 +914,10 @@ def build_disk_encryption_sets_list_associated_resources_request( # pylint: dis # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_restore_point_get_request( - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_snapshots_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -874,18 +925,9 @@ def build_disk_restore_point_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" - ), - "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), - "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -899,12 +941,8 @@ def build_disk_restore_point_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_restore_point_list_by_restore_point_request( # pylint: disable=name-too-long - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - subscription_id: str, - **kwargs: Any +def build_snapshots_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -915,15 +953,13 @@ def build_disk_restore_point_list_by_restore_point_request( # pylint: disable=n # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -937,34 +973,26 @@ def build_disk_restore_point_list_by_restore_point_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_restore_point_grant_access_request( # pylint: disable=name-too-long - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - subscription_id: str, - **kwargs: Any +def build_snapshots_get_request( + resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), - "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -973,40 +1001,32 @@ def build_disk_restore_point_grant_access_request( # pylint: disable=name-too-l _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disk_restore_point_revoke_access_request( # pylint: disable=name-too-long - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - subscription_id: str, - **kwargs: Any +def build_snapshots_create_or_update_request( + resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), - "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), + "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1015,12 +1035,14 @@ def build_disk_restore_point_revoke_access_request( # pylint: disable=name-too- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_create_or_update_request( +def build_snapshots_update_request( resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1036,8 +1058,10 @@ def build_snapshots_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } @@ -1051,17 +1075,16 @@ def build_snapshots_create_or_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_update_request( +def build_snapshots_delete_request( resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1070,8 +1093,10 @@ def build_snapshots_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } @@ -1081,30 +1106,31 @@ def build_snapshots_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_get_request( +def build_snapshots_grant_access_request( resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } @@ -1114,25 +1140,32 @@ def build_snapshots_get_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_delete_request( +def build_snapshots_revoke_access_request( resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endgetaccess", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), } @@ -1141,11 +1174,18 @@ def build_snapshots_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any + +def build_disk_restore_point_list_by_restore_point_request( # pylint: disable=name-too-long + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1156,11 +1196,17 @@ def build_snapshots_list_by_resource_group_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1174,7 +1220,14 @@ def build_snapshots_list_by_resource_group_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_disk_restore_point_get_request( + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1182,9 +1235,20 @@ def build_snapshots_list_request(subscription_id: str, **kwargs: Any) -> HttpReq accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), + "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1198,8 +1262,13 @@ def build_snapshots_list_request(subscription_id: str, **kwargs: Any) -> HttpReq return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_grant_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any +def build_disk_restore_point_grant_access_request( # pylint: disable=name-too-long + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1211,12 +1280,18 @@ def build_snapshots_grant_access_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), + "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1232,21 +1307,35 @@ def build_snapshots_grant_access_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_snapshots_revoke_access_request( - resource_group_name: str, snapshot_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) +def build_disk_restore_point_revoke_access_request( # pylint: disable=name-too-long + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-02")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "snapshotName": _SERIALIZER.url("snapshot_name", snapshot_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "vmRestorePointName": _SERIALIZER.url("vm_restore_point_name", vm_restore_point_name, "str"), + "diskRestorePointName": _SERIALIZER.url("disk_restore_point_name", disk_restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1254,17 +1343,20 @@ def build_snapshots_revoke_access_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class DisksOperations: + +class DiskAccessesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s - :attr:`disks` attribute. + :attr:`disk_accesses` attribute. """ models = _models @@ -1277,8 +1369,221 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.DiskAccess"]: + """Lists all the disk access resources under a subscription. + + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_accesses_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskAccessList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskAccess"]: + """Lists all the disk access resources under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either DiskAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_accesses_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskAccessList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> _models.DiskAccess: + """Gets information about a disk access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: DiskAccess or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + + _request = build_disk_accesses_get_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + def _create_or_update_initial( - self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccess, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1298,14 +1603,14 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access else: - _json = self._serialize.body(disk, "Disk") + _json = self._serialize.body(disk_access, "DiskAccess") - _request = build_disks_create_or_update_request( + _request = build_disk_accesses_create_or_update_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1332,10 +1637,15 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1343,27 +1653,29 @@ def _create_or_update_initial( def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: _models.Disk, - *, + disk_access_name: str, + disk_access: _models.DiskAccess, + *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates a disk. + ) -> LROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1371,47 +1683,54 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + disk_access_name: str, + disk_access: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates a disk. + ) -> LROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Required. - :type disk: IO[bytes] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Required. + :type disk_access: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_create_or_update( - self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Creates or updates a disk. + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccess, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DiskAccess]: + """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Put disk operation. Is either a Disk type - or a IO[bytes] type. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk or IO[bytes] - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Put disk access operation. + Is either a DiskAccess type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess or IO[bytes] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1419,15 +1738,15 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + disk_access_name=disk_access_name, + disk_access=disk_access, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1439,30 +1758,36 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", pipeline_response.http_response) + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Disk].from_continuation_token( + return LROPoller[_models.DiskAccess].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Disk]( + return LROPoller[_models.DiskAccess]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _update_initial( - self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1482,14 +1807,14 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk, (IOBase, bytes)): - _content = disk + if isinstance(disk_access, (IOBase, bytes)): + _content = disk_access else: - _json = self._serialize.body(disk, "DiskUpdate") + _json = self._serialize.body(disk_access, "DiskAccessUpdate") - _request = build_disks_update_request( + _request = build_disk_accesses_update_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -1516,10 +1841,15 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1527,27 +1857,29 @@ def _update_initial( def begin_update( self, resource_group_name: str, - disk_name: str, - disk: _models.DiskUpdate, + disk_access_name: str, + disk_access: _models.DiskAccessUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. + ) -> LROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1555,47 +1887,54 @@ def begin_update( def begin_update( self, resource_group_name: str, - disk_name: str, - disk: IO[bytes], + disk_access_name: str, + disk_access: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. + ) -> LROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Required. - :type disk: IO[bytes] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Required. + :type disk_access: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_update( - self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Disk]: - """Updates (patches) a disk. + self, + resource_group_name: str, + disk_access_name: str, + disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DiskAccess]: + """Updates (patches) a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param disk: Disk object supplied in the body of the Patch disk operation. Is either a - DiskUpdate type or a IO[bytes] type. Required. - :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Disk or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param disk_access: disk access object supplied in the body of the Patch disk access operation. + Is either a DiskAccessUpdate type or a IO[bytes] type. Required. + :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate or IO[bytes] + :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1603,15 +1942,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - disk=disk, + disk_access_name=disk_access_name, + disk_access=disk_access, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1623,42 +1962,31 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Disk", pipeline_response.http_response) + deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Disk].from_continuation_token( + return LROPoller[_models.DiskAccess].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Disk]( + return LROPoller[_models.DiskAccess]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _models.Disk: - """Gets information about a disk. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :return: Disk or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.Disk - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1671,11 +1999,11 @@ def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _model _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_get_request( + _request = build_disk_accesses_delete_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1683,82 +2011,45 @@ def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _model ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Disk", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + @distributed_trace + def begin_delete(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a disk access resource. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disks_delete_request( - resource_group_name=resource_group_name, - disk_name=disk_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a disk. - - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1774,7 +2065,7 @@ def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -1789,7 +2080,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1804,20 +2097,29 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Disk"]: - """Lists all the disks under a resource group. + def list_private_endpoint_connections( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1830,8 +2132,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - _request = build_disks_list_by_resource_group_request( + _request = build_disk_accesses_list_private_endpoint_connections_request( resource_group_name=resource_group_name, + disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1857,7 +2160,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1881,19 +2184,24 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Disk"]: - """Lists all the disks under a subscription. + def get_a_private_endpoint_connection( + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a disk access resource. - :return: An iterator like instance of either Disk or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1902,63 +2210,47 @@ def list(self, **kwargs: Any) -> Iterable["_models.Disk"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_disks_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_disk_accesses_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore - def _grant_access_initial( + def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -1979,14 +2271,15 @@ def _grant_access_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - _request = build_disks_grant_access_request( + _request = build_disk_accesses_update_a_private_endpoint_connection_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2013,92 +2306,121 @@ def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_grant_access( + def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: _models.GrantAccessData, + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_grant_access( + def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: IO[bytes], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_grant_access( + def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long self, resource_group_name: str, - disk_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + disk_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a disk. + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under disk access resource, this can't be used + to create a new private endpoint connection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a + IO[bytes] type. Required. + :type private_endpoint_connection: + ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2106,15 +2428,16 @@ def begin_grant_access( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._grant_access_initial( + raw_result = self._update_a_private_endpoint_connection_initial( resource_group_name=resource_group_name, - disk_name=disk_name, - grant_access_data=grant_access_data, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2126,7 +2449,7 @@ def begin_grant_access( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessUri", pipeline_response.http_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2140,17 +2463,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.AccessUri].from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.AccessUri]( + return LROPoller[_models.PrivateEndpointConnection]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: + def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2165,9 +2490,10 @@ def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disks_revoke_access_request( + _request = build_disk_accesses_delete_a_private_endpoint_connection_request( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2183,7 +2509,7 @@ def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwa response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2191,23 +2517,33 @@ def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwa map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_revoke_access(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> LROPoller[None]: - """Revokes access to a disk. + def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long + self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection under a disk access resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_name: The name of the managed disk that is being created. The name can't be changed - after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The - maximum name length is 80 characters. Required. - :type disk_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2221,9 +2557,10 @@ def begin_revoke_access(self, resource_group_name: str, disk_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._revoke_access_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( resource_group_name=resource_group_name, - disk_name=disk_name, + disk_access_name=disk_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -2254,34 +2591,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + @distributed_trace + def get_private_link_resources( + self, resource_group_name: str, disk_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under disk access resource. -class DiskAccessesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s - :attr:`disk_accesses` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _create_or_update_initial( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_access_name: The name of the disk access resource that is being created. The name + can't be changed after the disk encryption set is created. Supported characters for the name + are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_access_name: str + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2290,190 +2616,275 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access - else: - _json = self._serialize.body(disk_access, "DiskAccess") + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - _request = build_disk_accesses_create_or_update_request( + _request = build_disk_accesses_get_private_link_resources_request( resource_group_name=resource_group_name, disk_access_name=disk_access_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccess, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Required. - :type disk_access: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] - :raises ~azure.core.exceptions.HttpResponseError: - """ + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Creates or updates a disk access resource. + def list(self, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a subscription. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Put disk access operation. - Is either a DiskAccess type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess or IO[bytes] - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_encryption_sets_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + response = pipeline_response.http_response - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: + """Lists all the disk encryption sets under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disk_encryption_sets_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.DiskAccess].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[_models.DiskAccess]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any) -> _models.DiskEncryptionSet: + """Gets information about a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :return: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + + _request = build_disk_encryption_sets_get_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, ) + _request.url = self._client.format_url(_request.url) - def _update_initial( + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -2494,14 +2905,14 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_access, (IOBase, bytes)): - _content = disk_access + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set else: - _json = self._serialize.body(disk_access, "DiskAccessUpdate") + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - _request = build_disk_accesses_update_request( + _request = build_disk_encryption_sets_create_or_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2528,92 +2939,104 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: _models.DiskAccessUpdate, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSet, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: IO[bytes], + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type disk_access: IO[bytes] + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - disk_access: Union[_models.DiskAccessUpdate, IO[bytes]], + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DiskAccess]: - """Updates (patches) a disk access resource. + ) -> LROPoller[_models.DiskEncryptionSet]: + """Creates or updates a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param disk_access: disk access object supplied in the body of the Patch disk access operation. - Is either a DiskAccessUpdate type or a IO[bytes] type. Required. - :type disk_access: ~azure.mgmt.compute.v2024_03_02.models.DiskAccessUpdate or IO[bytes] - :return: An instance of LROPoller that returns either DiskAccess or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk + encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet or + IO[bytes] + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2621,15 +3044,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - disk_access=disk_access, + disk_encryption_set_name=disk_encryption_set_name, + disk_encryption_set=disk_encryption_set, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2641,85 +3064,37 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.DiskAccess].from_continuation_token( + return LROPoller[_models.DiskEncryptionSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.DiskAccess]( + return LROPoller[_models.DiskEncryptionSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> _models.DiskAccess: - """Gets information about a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: DiskAccess or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskAccess - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccess] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> Iterator[bytes]: + def _update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2728,17 +3103,29 @@ def _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwa } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_accesses_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk_encryption_set, (IOBase, bytes)): + _content = disk_encryption_set + else: + _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + + _request = build_disk_encryption_sets_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2752,7 +3139,7 @@ def _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwa response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -2760,82 +3147,290 @@ def _delete_initial(self, resource_group_name: str, disk_access_name: str, **kwa map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete(self, resource_group_name: str, disk_access_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a disk access resource. + @overload + def begin_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: _models.DiskEncryptionSetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Required. + :type disk_encryption_set: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DiskEncryptionSet]: + """Updates (patches) a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk + encryption set operation. Is either a DiskEncryptionSetUpdate type or a IO[bytes] type. + Required. + :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + disk_encryption_set=disk_encryption_set, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DiskEncryptionSet].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DiskEncryptionSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_disk_encryption_sets_delete_request( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a disk encryption set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskAccess"]: - """Lists all the disk access resources under a resource group. + def list_associated_resources( + self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any + ) -> Iterable[str]: + """Lists all resources that are encrypted with this disk encryption set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :param disk_encryption_set_name: The name of the disk encryption set that is being created. The + name can't be changed after the disk encryption set is created. Supported characters for the + name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. + :type disk_encryption_set_name: str + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + cls: ClsType[_models.ResourceUriList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2848,8 +3443,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - _request = build_disk_accesses_list_by_resource_group_request( + _request = build_disk_encryption_sets_list_associated_resources_request( resource_group_name=resource_group_name, + disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2875,7 +3471,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DiskAccessList", pipeline_response) + deserialized = self._deserialize("ResourceUriList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2898,19 +3494,40 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s + :attr:`disks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DiskAccess"]: - """Lists all the disk access resources under a subscription. + def list(self, **kwargs: Any) -> Iterable["_models.Disk"]: + """Lists all the disks under a subscription. - :return: An iterator like instance of either DiskAccess or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskAccess] + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskAccessList] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2923,7 +3540,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DiskAccess"]: def prepare_request(next_link=None): if not next_link: - _request = build_disk_accesses_list_request( + _request = build_disks_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2949,7 +3566,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DiskAccessList", pipeline_response) + deserialized = self._deserialize("DiskList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2973,19 +3590,96 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_private_link_resources( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources possible under disk access resource. - - :param resource_group_name: The name of the resource group. Required. + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Disk"]: + """Lists all the disks under a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateLinkResourceListResult + :return: An iterator like instance of either Disk or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_disks_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiskList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> _models.Disk: + """Gets information about a disk. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :return: Disk or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.Disk :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3000,11 +3694,11 @@ def get_private_link_resources( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - _request = build_disk_accesses_get_private_link_resources_request( + _request = build_disks_get_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3023,20 +3717,15 @@ def get_private_link_resources( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) + deserialized = self._deserialize("Disk", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any + def _create_or_update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3056,15 +3745,14 @@ def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-l content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IOBase, bytes)): - _content = private_endpoint_connection + if isinstance(disk, (IOBase, bytes)): + _content = disk else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + _json = self._serialize.body(disk, "Disk") - _request = build_disk_accesses_update_a_private_endpoint_connection_request( + _request = build_disks_create_or_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3091,113 +3779,94 @@ def _update_a_private_endpoint_connection_initial( # pylint: disable=name-too-l map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long + def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: _models.PrivateEndpointConnection, + disk_name: str, + disk: _models.Disk, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + ) -> LROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Required. - :type private_endpoint_connection: - ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long + def begin_create_or_update( self, resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: IO[bytes], + disk_name: str, + disk: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + ) -> LROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Required. - :type private_endpoint_connection: IO[bytes] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Required. + :type disk: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long - self, - resource_group_name: str, - disk_access_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection under disk access resource, this can't be used - to create a new private endpoint connection. + def begin_create_or_update( + self, resource_group_name: str, disk_name: str, disk: Union[_models.Disk, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Creates or updates a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection: private endpoint connection object supplied in the body of - the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a - IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Put disk operation. Is either a Disk type + or a IO[bytes] type. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.Disk or IO[bytes] + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3205,16 +3874,15 @@ def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection=private_endpoint_connection, + disk_name=disk_name, + disk=disk, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3226,91 +3894,32 @@ def begin_update_a_private_endpoint_connection( # pylint: disable=name-too-long kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + deserialized = self._deserialize("Disk", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + return LROPoller[_models.Disk].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.PrivateEndpointConnection]( + return LROPoller[_models.Disk]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get_a_private_endpoint_connection( - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets information about a private endpoint connection under a disk access resource. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_disk_accesses_get_a_private_endpoint_connection_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + def _update_initial( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3320,18 +3929,29 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-l } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_accesses_delete_a_private_endpoint_connection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(disk, (IOBase, bytes)): + _content = disk + else: + _json = self._serialize.body(disk, "DiskUpdate") + + _request = build_disks_update_request( resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3345,7 +3965,7 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-l response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -3353,186 +3973,146 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-l map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long - self, resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection under a disk access resource. + @overload + def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: _models.DiskUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Updates (patches) a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Updates (patches) a disk. - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Required. + :type disk: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_private_endpoint_connections( - self, resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """List information about private endpoint connections under a disk access resource. + def begin_update( + self, resource_group_name: str, disk_name: str, disk: Union[_models.DiskUpdate, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Disk]: + """Updates (patches) a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_access_name: The name of the disk access resource that is being created. The name - can't be changed after the disk encryption set is created. Supported characters for the name - are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_access_name: str - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.PrivateEndpointConnection] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param disk: Disk object supplied in the body of the Patch disk operation. Is either a + DiskUpdate type or a IO[bytes] type. Required. + :type disk: ~azure.mgmt.compute.v2024_03_02.models.DiskUpdate or IO[bytes] + :return: An instance of LROPoller that returns either Disk or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Disk] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_accesses_list_private_endpoint_connections_request( - resource_group_name=resource_group_name, - disk_access_name=disk_access_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DiskEncryptionSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s - :attr:`disk_encryption_sets` attribute. - """ + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + disk_name=disk_name, + disk=disk, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Disk", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Disk].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Disk]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _create_or_update_initial( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3541,29 +4121,17 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set - else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") - - _request = build_disk_encryption_sets_create_or_update_request( + _request = build_disks_delete_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3577,7 +4145,7 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -3585,114 +4153,46 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + def begin_delete(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Put disk - encryption set operation. Is either a DiskEncryptionSet type or a IO[bytes] type. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet or - IO[bytes] - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._delete_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + disk_name=disk_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3701,34 +4201,32 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.DiskEncryptionSet].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.DiskEncryptionSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _update_initial( + def _grant_access_initial( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3749,14 +4247,14 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(disk_encryption_set, (IOBase, bytes)): - _content = disk_encryption_set + if isinstance(grant_access_data, (IOBase, bytes)): + _content = grant_access_data else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSetUpdate") + _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_disk_encryption_sets_update_request( + _request = build_disks_grant_access_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3783,97 +4281,100 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSetUpdate, + disk_name: str, + grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + disk_name: str, + grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Required. - :type disk_encryption_set: IO[bytes] + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Required. + :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Updates (patches) a disk encryption set. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a disk. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :param disk_encryption_set: disk encryption set object supplied in the body of the Patch disk - encryption set operation. Is either a DiskEncryptionSetUpdate type or a IO[bytes] type. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either DiskEncryptionSet or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :type resource_group_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access + operation. Is either a GrantAccessData type or a IO[bytes] type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3881,15 +4382,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) + cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._grant_access_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - disk_encryption_set=disk_encryption_set, + disk_name=disk_name, + grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3901,87 +4402,31 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) + deserialized = self._deserialize("AccessUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.DiskEncryptionSet].from_continuation_token( + return LROPoller[_models.AccessUri].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.DiskEncryptionSet]( + return LROPoller[_models.AccessUri]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get(self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any) -> _models.DiskEncryptionSet: - """Gets information about a disk encryption set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) - - _request = build_disk_encryption_sets_get_request( - resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiskEncryptionSet", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: + def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3996,9 +4441,9 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_encryption_sets_delete_request( + _request = build_disks_revoke_access_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4014,7 +4459,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -4022,23 +4467,29 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete(self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a disk encryption set. + def begin_revoke_access(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> LROPoller[None]: + """Revokes access to a disk. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str + :param disk_name: The name of the managed disk that is being created. The name can't be changed + after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The + maximum name length is 80 characters. Required. + :type disk_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -4052,9 +4503,9 @@ def begin_delete(self, resource_group_name: str, disk_encryption_set_name: str, lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._revoke_access_initial( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, + disk_name=disk_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4069,7 +4520,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -4083,96 +4536,40 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_encryption_sets_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s + :attr:`snapshots` attribute. + """ - return pipeline_response + models = _models - return ItemPaged(get_next, extract_data) + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: - """Lists all the disk encryption sets under a subscription. + def list(self, **kwargs: Any) -> Iterable["_models.Snapshot"]: + """Lists snapshots under a subscription. - :return: An iterator like instance of either DiskEncryptionSet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskEncryptionSetList] = kwargs.pop("cls", None) + cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4185,7 +4582,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DiskEncryptionSet"]: def prepare_request(next_link=None): if not next_link: - _request = build_disk_encryption_sets_list_request( + _request = build_snapshots_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4211,7 +4608,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSetList", pipeline_response) + deserialized = self._deserialize("SnapshotList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4235,26 +4632,21 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_associated_resources( - self, resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable[str]: - """Lists all resources that are encrypted with this disk encryption set. + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Snapshot"]: + """Lists snapshots under a resource group. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param disk_encryption_set_name: The name of the disk encryption set that is being created. The - name can't be changed after the disk encryption set is created. Supported characters for the - name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. Required. - :type disk_encryption_set_name: str - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[str] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either Snapshot or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.ResourceUriList] = kwargs.pop("cls", None) + cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4267,9 +4659,8 @@ def list_associated_resources( def prepare_request(next_link=None): if not next_link: - _request = build_disk_encryption_sets_list_associated_resources_request( + _request = build_snapshots_list_by_resource_group_request( resource_group_name=resource_group_name, - disk_encryption_set_name=disk_encryption_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4295,7 +4686,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUriList", pipeline_response) + deserialized = self._deserialize("SnapshotList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4318,50 +4709,19 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class DiskRestorePointOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s - :attr:`disk_restore_point` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace - def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - **kwargs: Any - ) -> _models.DiskRestorePoint: - """Get disk restorePoint resource. + def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: + """Gets information about a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :return: DiskRestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :return: Snapshot or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4376,13 +4736,11 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - _request = build_disk_restore_point_get_request( + _request = build_snapshots_get_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4401,108 +4759,15 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DiskRestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_restore_point( - self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePoint"]: - """Lists diskRestorePoints under a vmRestorePoint. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.DiskRestorePointList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_disk_restore_point_list_by_restore_point_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiskRestorePointList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _grant_access_initial( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any + def _create_or_update_initial( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4522,16 +4787,14 @@ def _grant_access_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(grant_access_data, (IOBase, bytes)): - _content = grant_access_data + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot else: - _json = self._serialize.body(grant_access_data, "GrantAccessData") + _json = self._serialize.body(snapshot, "Snapshot") - _request = build_disk_restore_point_grant_access_request( + _request = build_snapshots_create_or_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4558,110 +4821,94 @@ def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_grant_access( + def begin_create_or_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: _models.GrantAccessData, + snapshot_name: str, + snapshot: _models.Snapshot, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_grant_access( + def begin_create_or_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: IO[bytes], + snapshot_name: str, + snapshot: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Required. - :type grant_access_data: IO[bytes] + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. + :type snapshot: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_grant_access( - self, - resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, - grant_access_data: Union[_models.GrantAccessData, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AccessUri]: - """Grants access to a diskRestorePoint. + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :param grant_access_data: Access data object supplied in the body of the get disk access - operation. Is either a GrantAccessData type or a IO[bytes] type. Required. - :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] - :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Put disk operation. Is either a + Snapshot type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot or IO[bytes] + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4669,17 +4916,15 @@ def begin_grant_access( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._grant_access_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, - grant_access_data=grant_access_data, + snapshot_name=snapshot_name, + snapshot=snapshot, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4691,7 +4936,7 @@ def begin_grant_access( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AccessUri", pipeline_response.http_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -4705,22 +4950,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.AccessUri].from_continuation_token( + return LROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.AccessUri]( + return LROPoller[_models.Snapshot]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _revoke_access_initial( + def _update_initial( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4731,19 +4975,29 @@ def _revoke_access_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_disk_restore_point_revoke_access_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(snapshot, (IOBase, bytes)): + _content = snapshot + else: + _json = self._serialize.body(snapshot, "SnapshotUpdate") + + _request = build_snapshots_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -4765,53 +5019,118 @@ def _revoke_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: _models.SnapshotUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. + Required. + :type snapshot: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_revoke_access( + def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - vm_restore_point_name: str, - disk_restore_point_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Revokes access to a diskRestorePoint. + ) -> LROPoller[_models.Snapshot]: + """Updates (patches) a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection that the disk - restore point belongs. Required. - :type restore_point_collection_name: str - :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point - belongs. Required. - :type vm_restore_point_name: str - :param disk_restore_point_name: The name of the disk restore point created. Required. - :type disk_restore_point_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param snapshot_name: The name of the snapshot that is being created. The name can't be changed + after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. + The max name length is 80 characters. Required. + :type snapshot_name: str + :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is + either a SnapshotUpdate type or a IO[bytes] type. Required. + :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate or IO[bytes] + :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._revoke_access_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - vm_restore_point_name=vm_restore_point_name, - disk_restore_point_name=disk_restore_point_name, + snapshot_name=snapshot_name, + snapshot=snapshot, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4820,9 +5139,11 @@ def begin_revoke_access( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: PollingMethod = cast( @@ -4833,38 +5154,17 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class SnapshotsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s - :attr:`snapshots` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return LROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _create_or_update_initial( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: + def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4873,29 +5173,17 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot - else: - _json = self._serialize.body(snapshot, "Snapshot") - - _request = build_snapshots_create_or_update_request( + _request = build_snapshots_delete_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -4909,112 +5197,54 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: _models.Snapshot, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - def begin_create_or_update( - self, - resource_group_name: str, - snapshot_name: str, - snapshot: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Required. - :type snapshot: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] - :raises ~azure.core.exceptions.HttpResponseError: - """ + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Creates or updates a snapshot. + def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Put disk operation. Is either a - Snapshot type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.Snapshot or IO[bytes] - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._delete_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, - snapshot=snapshot, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -5023,34 +5253,32 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Snapshot].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Snapshot]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _update_initial( + def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -5071,12 +5299,12 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(snapshot, (IOBase, bytes)): - _content = snapshot + if isinstance(grant_access_data, (IOBase, bytes)): + _content = grant_access_data else: - _json = self._serialize.body(snapshot, "SnapshotUpdate") + _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_snapshots_update_request( + _request = build_snapshots_grant_access_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -5105,92 +5333,100 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: _models.SnapshotUpdate, + grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: IO[bytes], + grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. - Required. - :type snapshot: IO[bytes] + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Required. + :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Snapshot]: - """Updates (patches) a snapshot. + ) -> LROPoller[_models.AccessUri]: + """Grants access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The max name length is 80 characters. Required. :type snapshot_name: str - :param snapshot: Snapshot object supplied in the body of the Patch snapshot operation. Is - either a SnapshotUpdate type or a IO[bytes] type. Required. - :type snapshot: ~azure.mgmt.compute.v2024_03_02.models.SnapshotUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :param grant_access_data: Access data object supplied in the body of the get snapshot access + operation. Is either a GrantAccessData type or a IO[bytes] type. Required. + :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] + :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_03_02.models.AccessUri] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5198,15 +5434,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[_models.AccessUri] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._grant_access_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, - snapshot=snapshot, + grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5218,85 +5454,31 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) + deserialized = self._deserialize("AccessUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Snapshot].from_continuation_token( + return LROPoller[_models.AccessUri].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Snapshot]( + return LROPoller[_models.AccessUri]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> _models.Snapshot: - """Gets information about a snapshot. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :return: Snapshot or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_03_02.models.Snapshot - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - - _request = build_snapshots_get_request( - resource_group_name=resource_group_name, - snapshot_name=snapshot_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Snapshot", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> Iterator[bytes]: + def _revoke_access_initial(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5311,7 +5493,7 @@ def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_delete_request( + _request = build_snapshots_revoke_access_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -5329,7 +5511,7 @@ def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5337,18 +5519,24 @@ def _delete_initial(self, resource_group_name: str, snapshot_name: str, **kwargs map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a snapshot. + def begin_revoke_access(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: + """Revokes access to a snapshot. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param snapshot_name: The name of the snapshot that is being created. The name can't be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. @@ -5367,7 +5555,7 @@ def begin_delete(self, resource_group_name: str, snapshot_name: str, **kwargs: A lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._revoke_access_initial( resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, @@ -5384,7 +5572,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -5398,21 +5588,51 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Snapshot"]: - """Lists snapshots under a resource group. + def list_by_restore_point( + self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any + ) -> Iterable["_models.DiskRestorePoint"]: + """Lists diskRestorePoints under a vmRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :return: An iterator like instance of either DiskRestorePoint or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) + cls: ClsType[_models.DiskRestorePointListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5425,8 +5645,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - _request = build_snapshots_list_by_resource_group_request( + _request = build_disk_restore_point_list_by_restore_point_request( resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5452,7 +5674,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) + deserialized = self._deserialize("DiskRestorePointListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -5476,19 +5698,31 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Snapshot"]: - """Lists snapshots under a subscription. + def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> _models.DiskRestorePoint: + """Get disk restorePoint resource. - :return: An iterator like instance of either Snapshot or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_03_02.models.Snapshot] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :return: DiskRestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskRestorePoint :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) - cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5497,62 +5731,48 @@ def list(self, **kwargs: Any) -> Iterable["_models.Snapshot"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_snapshots_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[_models.DiskRestorePoint] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_disk_restore_point_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("SnapshotList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("DiskRestorePoint", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore def _grant_access_initial( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: @@ -5579,9 +5799,11 @@ def _grant_access_initial( else: _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_snapshots_grant_access_request( + _request = build_disk_restore_point_grant_access_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5608,10 +5830,15 @@ def _grant_access_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -5619,21 +5846,28 @@ def _grant_access_initial( def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Required. :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -5648,21 +5882,28 @@ def begin_grant_access( def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Required. :type grant_access_data: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -5677,19 +5918,26 @@ def begin_grant_access( def begin_grant_access( self, resource_group_name: str, - snapshot_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AccessUri]: - """Grants access to a snapshot. + """Grants access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str - :param grant_access_data: Access data object supplied in the body of the get snapshot access + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str + :param grant_access_data: Access data object supplied in the body of the get disk access operation. Is either a GrantAccessData type or a IO[bytes] type. Required. :type grant_access_data: ~azure.mgmt.compute.v2024_03_02.models.GrantAccessData or IO[bytes] :return: An instance of LROPoller that returns either AccessUri or the result of cls(response) @@ -5708,7 +5956,9 @@ def begin_grant_access( if cont_token is None: raw_result = self._grant_access_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, grant_access_data=grant_access_data, api_version=api_version, content_type=content_type, @@ -5745,7 +5995,14 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _revoke_access_initial(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> Iterator[bytes]: + def _revoke_access_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5760,9 +6017,11 @@ def _revoke_access_initial(self, resource_group_name: str, snapshot_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_snapshots_revoke_access_request( + _request = build_disk_restore_point_revoke_access_request( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5786,23 +6045,40 @@ def _revoke_access_initial(self, resource_group_name: str, snapshot_name: str, * map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_revoke_access(self, resource_group_name: str, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: - """Revokes access to a snapshot. + def begin_revoke_access( + self, + resource_group_name: str, + restore_point_collection_name: str, + vm_restore_point_name: str, + disk_restore_point_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Revokes access to a diskRestorePoint. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param snapshot_name: The name of the snapshot that is being created. The name can't be changed - after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. - The max name length is 80 characters. Required. - :type snapshot_name: str + :param restore_point_collection_name: The name of the restore point collection that the disk + restore point belongs. Required. + :type restore_point_collection_name: str + :param vm_restore_point_name: The name of the vm restore point that the disk disk restore point + belongs. Required. + :type vm_restore_point_name: str + :param disk_restore_point_name: The name of the DiskRestorePoint. Required. + :type disk_restore_point_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -5818,7 +6094,9 @@ def begin_revoke_access(self, resource_group_name: str, snapshot_name: str, **kw if cont_token is None: raw_result = self._revoke_access_initial( resource_group_name=resource_group_name, - snapshot_name=snapshot_name, + restore_point_collection_name=restore_point_collection_name, + vm_restore_point_name=vm_restore_point_name, + disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py index 5c780f4bc783..de9fee5a7aeb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_compute_management_client.py @@ -56,82 +56,81 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar operations: Operations operations :vartype operations: azure.mgmt.compute.v2024_11_01.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: + azure.mgmt.compute.v2024_11_01.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.v2024_11_01.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: + azure.mgmt.compute.v2024_11_01.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.v2024_11_01.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.v2024_11_01.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineRunCommandsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.compute.v2024_11_01.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineSizesOperations :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations :vartype virtual_machine_scale_sets: azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionsOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.compute.v2024_11_01.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionImagesOperations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_11_01.operations.AvailabilitySetsOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineSizesOperations :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations :vartype proximity_placement_groups: azure.mgmt.compute.v2024_11_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_11_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2024_11_01.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.operations.SshPublicKeysOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_11_01.operations.ImagesOperations :ivar restore_point_collections: RestorePointCollectionsOperations operations :vartype restore_point_collections: azure.mgmt.compute.v2024_11_01.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_11_01.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_11_01.operations.CapacityReservationGroupsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.operations.SshPublicKeysOperations :ivar capacity_reservations: CapacityReservationsOperations operations :vartype capacity_reservations: azure.mgmt.compute.v2024_11_01.operations.CapacityReservationsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_11_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_11_01.operations.VirtualMachineRunCommandsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: azure.mgmt.compute.v2024_11_01.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.v2024_11_01.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMExtensionsOperations :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations operations :vartype virtual_machine_scale_set_vm_run_commands: azure.mgmt.compute.v2024_11_01.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.v2024_11_01.operations.VirtualMachineExtensionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -177,77 +176,77 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self.availability_sets = AvailabilitySetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self.capacity_reservation_groups = CapacityReservationGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self.dedicated_host_groups = DedicatedHostGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self.virtual_machine_images = VirtualMachineImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self.log_analytics = LogAnalyticsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machines = VirtualMachinesOperations( + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_images = VirtualMachineImagesOperations( + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self.virtual_machines = VirtualMachinesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.availability_sets = AvailabilitySetsOperations( + self.virtual_machine_sizes = VirtualMachineSizesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.proximity_placement_groups = ProximityPlacementGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( + self.restore_point_collections = RestorePointCollectionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.dedicated_hosts = DedicatedHostsOperations( + self.ssh_public_keys = SshPublicKeysOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.ssh_public_keys = SshPublicKeysOperations( + self.capacity_reservations = CapacityReservationsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.restore_point_collections = RestorePointCollectionsOperations( + self.dedicated_hosts = DedicatedHostsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.restore_points = RestorePointsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.capacity_reservations = CapacityReservationsOperations( + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.log_analytics = LogAnalyticsOperations( + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-11-01" + ) def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py index da0ddc20eae1..79bccfe20953 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_configuration.py @@ -25,8 +25,7 @@ class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json index 373d6f1356a8..fef949aeae83 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_metadata.json @@ -24,7 +24,7 @@ }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true, "method_location": "positional" @@ -39,7 +39,7 @@ }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -106,30 +106,30 @@ }, "operation_groups": { "operations": "Operations", + "availability_sets": "AvailabilitySetsOperations", + "capacity_reservation_groups": "CapacityReservationGroupsOperations", + "dedicated_host_groups": "DedicatedHostGroupsOperations", + "images": "ImagesOperations", + "virtual_machine_images_edge_zone": "VirtualMachineImagesEdgeZoneOperations", + "virtual_machine_images": "VirtualMachineImagesOperations", + "log_analytics": "LogAnalyticsOperations", + "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", + "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations", "usage": "UsageOperations", - "virtual_machine_sizes": "VirtualMachineSizesOperations", "virtual_machine_scale_sets": "VirtualMachineScaleSetsOperations", - "virtual_machine_scale_set_extensions": "VirtualMachineScaleSetExtensionsOperations", - "virtual_machine_scale_set_rolling_upgrades": "VirtualMachineScaleSetRollingUpgradesOperations", - "virtual_machine_scale_set_vm_extensions": "VirtualMachineScaleSetVMExtensionsOperations", - "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations", - "virtual_machine_extensions": "VirtualMachineExtensionsOperations", "virtual_machines": "VirtualMachinesOperations", - "virtual_machine_images": "VirtualMachineImagesOperations", - "virtual_machine_images_edge_zone": "VirtualMachineImagesEdgeZoneOperations", - "virtual_machine_extension_images": "VirtualMachineExtensionImagesOperations", - "availability_sets": "AvailabilitySetsOperations", + "virtual_machine_sizes": "VirtualMachineSizesOperations", "proximity_placement_groups": "ProximityPlacementGroupsOperations", - "dedicated_host_groups": "DedicatedHostGroupsOperations", - "dedicated_hosts": "DedicatedHostsOperations", - "ssh_public_keys": "SshPublicKeysOperations", - "images": "ImagesOperations", "restore_point_collections": "RestorePointCollectionsOperations", - "restore_points": "RestorePointsOperations", - "capacity_reservation_groups": "CapacityReservationGroupsOperations", + "ssh_public_keys": "SshPublicKeysOperations", "capacity_reservations": "CapacityReservationsOperations", - "log_analytics": "LogAnalyticsOperations", - "virtual_machine_run_commands": "VirtualMachineRunCommandsOperations", - "virtual_machine_scale_set_vm_run_commands": "VirtualMachineScaleSetVMRunCommandsOperations" + "dedicated_hosts": "DedicatedHostsOperations", + "restore_points": "RestorePointsOperations", + "virtual_machine_scale_set_rolling_upgrades": "VirtualMachineScaleSetRollingUpgradesOperations", + "virtual_machine_scale_set_extensions": "VirtualMachineScaleSetExtensionsOperations", + "virtual_machine_scale_set_vms": "VirtualMachineScaleSetVMsOperations", + "virtual_machine_scale_set_vm_extensions": "VirtualMachineScaleSetVMExtensionsOperations", + "virtual_machine_scale_set_vm_run_commands": "VirtualMachineScaleSetVMRunCommandsOperations", + "virtual_machine_extensions": "VirtualMachineExtensionsOperations" } } diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py index b0d2e626c38c..0867bc2eb313 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_compute_management_client.py @@ -56,84 +56,83 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar operations: Operations operations :vartype operations: azure.mgmt.compute.v2024_11_01.aio.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: + azure.mgmt.compute.v2024_11_01.aio.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.v2024_11_01.aio.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: + azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.v2024_11_01.aio.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.v2024_11_01.aio.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineRunCommandsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.compute.v2024_11_01.aio.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineSizesOperations :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations :vartype virtual_machine_scale_sets: azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionsOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_11_01.aio.operations.AvailabilitySetsOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineSizesOperations :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations :vartype proximity_placement_groups: azure.mgmt.compute.v2024_11_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.aio.operations.SshPublicKeysOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_11_01.aio.operations.ImagesOperations :ivar restore_point_collections: RestorePointCollectionsOperations operations :vartype restore_point_collections: azure.mgmt.compute.v2024_11_01.aio.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_11_01.aio.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_11_01.aio.operations.CapacityReservationGroupsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.v2024_11_01.aio.operations.SshPublicKeysOperations :ivar capacity_reservations: CapacityReservationsOperations operations :vartype capacity_reservations: azure.mgmt.compute.v2024_11_01.aio.operations.CapacityReservationsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_11_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineRunCommandsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: + azure.mgmt.compute.v2024_11_01.aio.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.v2024_11_01.aio.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations :ivar virtual_machine_scale_set_vm_run_commands: VirtualMachineScaleSetVMRunCommandsOperations operations :vartype virtual_machine_scale_set_vm_run_commands: azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.v2024_11_01.aio.operations.VirtualMachineExtensionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -179,77 +178,77 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-11-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self.availability_sets = AvailabilitySetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self.capacity_reservation_groups = CapacityReservationGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self.dedicated_host_groups = DedicatedHostGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self.virtual_machine_images = VirtualMachineImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self.log_analytics = LogAnalyticsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machines = VirtualMachinesOperations( + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_images = VirtualMachineImagesOperations( + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self.virtual_machines = VirtualMachinesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.availability_sets = AvailabilitySetsOperations( + self.virtual_machine_sizes = VirtualMachineSizesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.proximity_placement_groups = ProximityPlacementGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( + self.restore_point_collections = RestorePointCollectionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.dedicated_hosts = DedicatedHostsOperations( + self.ssh_public_keys = SshPublicKeysOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.ssh_public_keys = SshPublicKeysOperations( + self.capacity_reservations = CapacityReservationsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-11-01") - self.restore_point_collections = RestorePointCollectionsOperations( + self.dedicated_hosts = DedicatedHostsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.restore_points = RestorePointsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.capacity_reservations = CapacityReservationsOperations( + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.log_analytics = LogAnalyticsOperations( + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-11-01" ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-11-01" + ) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py index 5452cdff0995..65be166ddc7b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/_configuration.py @@ -25,8 +25,7 @@ class ComputeManagementClientConfiguration: # pylint: disable=too-many-instance :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2024-11-01". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py index 5cc9a11e2341..6718c8ecb4f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/__init__.py @@ -13,31 +13,31 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore +from ._operations import AvailabilitySetsOperations # type: ignore +from ._operations import CapacityReservationGroupsOperations # type: ignore +from ._operations import DedicatedHostGroupsOperations # type: ignore +from ._operations import ImagesOperations # type: ignore +from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore +from ._operations import VirtualMachineImagesOperations # type: ignore +from ._operations import LogAnalyticsOperations # type: ignore +from ._operations import VirtualMachineExtensionImagesOperations # type: ignore +from ._operations import VirtualMachineRunCommandsOperations # type: ignore from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore +from ._operations import VirtualMachineSizesOperations # type: ignore from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import DedicatedHostGroupsOperations # type: ignore -from ._operations import DedicatedHostsOperations # type: ignore -from ._operations import SshPublicKeysOperations # type: ignore -from ._operations import ImagesOperations # type: ignore from ._operations import RestorePointCollectionsOperations # type: ignore -from ._operations import RestorePointsOperations # type: ignore -from ._operations import CapacityReservationGroupsOperations # type: ignore +from ._operations import SshPublicKeysOperations # type: ignore from ._operations import CapacityReservationsOperations # type: ignore -from ._operations import LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore +from ._operations import DedicatedHostsOperations # type: ignore +from ._operations import RestorePointsOperations # type: ignore +from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore +from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore +from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore +from ._operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore +from ._operations import VirtualMachineExtensionsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -45,31 +45,31 @@ __all__ = [ "Operations", + "AvailabilitySetsOperations", + "CapacityReservationGroupsOperations", + "DedicatedHostGroupsOperations", + "ImagesOperations", + "VirtualMachineImagesEdgeZoneOperations", + "VirtualMachineImagesOperations", + "LogAnalyticsOperations", + "VirtualMachineExtensionImagesOperations", + "VirtualMachineRunCommandsOperations", "UsageOperations", - "VirtualMachineSizesOperations", "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "VirtualMachineExtensionsOperations", "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "VirtualMachineExtensionImagesOperations", - "AvailabilitySetsOperations", + "VirtualMachineSizesOperations", "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "ImagesOperations", "RestorePointCollectionsOperations", - "RestorePointsOperations", - "CapacityReservationGroupsOperations", + "SshPublicKeysOperations", "CapacityReservationsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", + "DedicatedHostsOperations", + "RestorePointsOperations", + "VirtualMachineScaleSetRollingUpgradesOperations", + "VirtualMachineScaleSetExtensionsOperations", + "VirtualMachineScaleSetVMsOperations", + "VirtualMachineScaleSetVMExtensionsOperations", "VirtualMachineScaleSetVMRunCommandsOperations", + "VirtualMachineExtensionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py index c803b24faa74..acecf6501150 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/aio/operations/_operations.py @@ -249,20 +249,19 @@ def __init__(self, *args, **kwargs) -> None: self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ComputeOperationValue"]: - """Gets a list of compute operations. + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """List the operations for the provider. - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ComputeOperationValue] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ComputeOperationListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -300,11 +299,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ComputeOperationListResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -317,21 +316,22 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) -class UsageOperations: +class AvailabilitySetsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. + :attr:`availability_sets` attribute. """ models = _models @@ -345,21 +345,24 @@ def __init__(self, *args, **kwargs) -> None: self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: - """Gets, for the specified location, the current compute resource usage information as well as the - limits for compute resources under the subscription. + def list_by_subscription( + self, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.AvailabilitySet"]: + """Lists all availability sets in a subscription. - :param location: The location for which resource usage is queried. Required. - :type location: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Usage] + :keyword expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -372,9 +375,9 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - _request = build_usage_list_request( - location=location, + _request = build_availability_sets_list_by_subscription_request( subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -399,7 +402,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -422,44 +425,23 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class VirtualMachineSizesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace - def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.AvailabilitySet"]: + """Lists all availability sets in a resource group. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AvailabilitySet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -472,8 +454,8 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMa def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_sizes_list_request( - location=location, + _request = build_availability_sets_list_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -499,11 +481,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -522,117 +504,19 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: + """Retrieves information about an availability set. -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: - """Gets all the VM scale sets under the specified subscription for the specified location. - - :param location: The location for which VM scale sets under the subscription are queried. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_sets_list_by_location_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -641,53 +525,34 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_create_or_update_request( + _request = build_availability_sets_get_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -695,174 +560,81 @@ async def _create_or_update_initial( return deserialized # type: ignore @overload - async def begin_create_or_update( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, + availability_set_name: str, + parameters: _models.AvailabilitySet, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, + availability_set_name: str, parameters: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Required. :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + availability_set_name: str, + parameters: Union[_models.AvailabilitySet, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Is either a + AvailabilitySet type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -876,7 +648,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -884,14 +656,12 @@ async def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") + _json = self._serialize.body(parameters, "AvailabilitySet") - _request = build_virtual_machine_scale_sets_update_request( + _request = build_availability_sets_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -901,8 +671,7 @@ async def _update_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -910,14 +679,10 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -925,210 +690,129 @@ async def _update_initial( return deserialized # type: ignore @overload - async def begin_update( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, + availability_set_name: str, + parameters: _models.AvailabilitySetUpdate, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, + availability_set_name: str, parameters: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Required. :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + availability_set_name: str, + parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Is either a + AvailabilitySetUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _json = self._serialize.body(parameters, "AvailabilitySetUpdate") - _request = build_virtual_machine_scale_sets_delete_request( + _request = build_availability_sets_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1136,84 +820,69 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a VM scale set. + async def delete(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> None: + """Delete an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword force_deletion: Optional parameter to force delete a VM scale set. (Feature in - Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_availability_sets_delete_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a virtual machine scale set. + async def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> None: + """Cancel the migration operation on an Availability Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the - UserData property of the VM scale set that was provided by the user during the VM scale set - Create/Update operation. "userData" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1228,13 +897,12 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_get_request( + _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -1248,24 +916,18 @@ async def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - async def _deallocate_initial( + async def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1286,19 +948,18 @@ async def _deallocate_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + if parameters is not None: + _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") else: _json = None - _request = build_virtual_machine_scale_sets_deallocate_request( + _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - hibernate=hibernate, api_version=api_version, content_type=content_type, json=_json, @@ -1316,7 +977,7 @@ async def _deallocate_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -1324,40 +985,38 @@ async def _deallocate_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_deallocate( + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + availability_set_name: str, + parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, *, - hibernate: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1367,31 +1026,26 @@ async def begin_deallocate( """ @overload - async def begin_deallocate( + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + availability_set_name: str, + parameters: Optional[IO[bytes]] = None, *, - hibernate: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1401,31 +1055,25 @@ async def begin_deallocate( """ @distributed_trace_async - async def begin_deallocate( + async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput + or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1440,11 +1088,10 @@ async def begin_deallocate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deallocate_initial( + raw_result = await self._convert_to_virtual_machine_scale_set_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - hibernate=hibernate, + availability_set_name=availability_set_name, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1460,7 +1107,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -1474,15 +1123,91 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_instances_initial( + @overload + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, *, - force_deletion: Optional[bool] = None, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1496,21 +1221,20 @@ async def _delete_instances_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - _request = build_virtual_machine_scale_sets_delete_instances_request( + _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, content_type=content_type, json=_json, @@ -1520,175 +1244,100 @@ async def _delete_instances_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - async def begin_delete_instances( + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, *, - force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_delete_instances( + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], + availability_set_name: str, + parameters: IO[bytes], *, - force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Required. - :type vm_instance_i_ds: IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_delete_instances( + async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - force_deletion=force_deletion, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.VirtualMachineScaleSetInstanceView: - """Gets the status of a VM scale set instance. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: VirtualMachineScaleSetInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceView + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + or IO[bytes] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1699,17 +1348,29 @@ async def get_instance_view( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_get_instance_view_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -1722,34 +1383,35 @@ async def get_instance_view( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM scale sets under a resource group. + def list_available_sizes( + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineSize"]: + """Lists all available virtual machine sizes that can be used to create a new virtual machine in + an existing availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1762,8 +1424,9 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_request( + _request = build_availability_sets_list_available_sizes_request( resource_group_name=resource_group_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1789,7 +1452,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1812,23 +1475,64 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. + def list_by_subscription( + self, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.CapacityReservationGroup"]: + """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in + the response to get the next page of capacity reservation groups. - :return: An iterator like instance of either VirtualMachineScaleSet or the result of + :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) + specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are + associated to capacity reservation group in the response. Known values are: + "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups + :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. + :code:`
` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation + group resources created in the subscription. :code:`
` 'SharedWithSubscription' enables + fetching Resource Ids for all capacity reservation group resources shared with the + subscription. :code:`
` 'All' enables fetching Resource Ids for all capacity reservation + group resources shared with the subscription and created in the subscription. Known values are: + "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. + :paramtype resource_ids_only: str or + ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1841,8 +1545,10 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleS def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_all_request( + _request = build_capacity_reservation_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, + expand=expand, + resource_ids_only=resource_ids_only, api_version=api_version, headers=_headers, params=_params, @@ -1867,7 +1573,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListWithLinkResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1891,27 +1597,36 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. + def list_by_resource_group( + self, + resource_group_name: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.CapacityReservationGroup"]: + """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink + property in the response to get the next page of capacity reservation groups. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of + :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) + specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are + associated to capacity reservation group in the response. Known values are: + "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1924,10 +1639,10 @@ def list_skus( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_skus_request( + _request = build_capacity_reservation_groups_list_by_resource_group_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -1952,7 +1667,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1975,29 +1690,33 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.UpgradeOperationHistoricalStatusInfo"]: - # pylint: disable=line-too-long - """Gets list of OS upgrades on a VM scale set instance. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + *, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation that retrieves information about a capacity reservation group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the capacity reservations under the capacity reservation group + which is a snapshot of the runtime properties of a capacity reservation that is managed by the + platform and can change outside of control plane operations. "instanceView" Default value is + None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2006,69 +1725,123 @@ def get_os_upgrade_history( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_capacity_reservation_groups_get_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore - async def _power_off_initial( + @overload + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + capacity_reservation_group_name: str, + parameters: _models.CapacityReservationGroup, *, - skip_shutdown: bool = False, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroup, IO[bytes]], + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a + CapacityReservationGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2082,24 +1855,20 @@ async def _power_off_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "CapacityReservationGroup") - _request = build_virtual_machine_scale_sets_power_off_request( + _request = build_capacity_reservation_groups_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, json=_json, @@ -2109,23 +1878,18 @@ async def _power_off_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2133,158 +1897,87 @@ async def _power_off_initial( return deserialized # type: ignore @overload - async def begin_power_off( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + capacity_reservation_group_name: str, + parameters: _models.CapacityReservationGroupUpdate, *, - skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_power_off( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + capacity_reservation_group_name: str, + parameters: IO[bytes], *, - skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. + Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_power_off( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - skip_shutdown: bool = False, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. Is + either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate or + IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - skip_shutdown=skip_shutdown, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _restart_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2298,22 +1991,19 @@ async def _restart_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") - _request = build_virtual_machine_scale_sets_restart_request( + _request = build_capacity_reservation_groups_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -2324,156 +2014,40 @@ async def _restart_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. + async def delete(self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any) -> None: + """The operation to delete a capacity reservation group. This operation is allowed only if all the + associated resources are disassociated from the reservation group and all capacity reservations + under the reservation group have also been deleted. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2482,183 +2056,73 @@ async def _start_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_start_request( + _request = build_capacity_reservation_groups_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @overload - async def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts one or more virtual machines in a VM scale set. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. + """ - @overload - async def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts one or more virtual machines in a VM scale set. + models = _models - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace_async - async def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts one or more virtual machines in a VM scale set. + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DedicatedHostGroup"]: + """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the + response to get the next page of dedicated host groups. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - async def _reapply_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2667,113 +2131,165 @@ async def _reapply_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_virtual_machine_scale_sets_reapply_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_dedicated_host_groups_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - response = pipeline_response.http_response + async def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + async def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def begin_reapply( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine - Instances. + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DedicatedHostGroup"]: + """Lists all of the dedicated host groups in the specified resource group. Use the nextLink + property in the response to get the next page of dedicated host groups. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reapply_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def prepare_request(next_link=None): + if not next_link: + + _request = build_dedicated_host_groups_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - async def _redeploy_initial( + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> _models.DedicatedHostGroup: + """Retrieves information about a dedicated host group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is + not supported for dedicated host group. Known values are: "instanceView", "userData", and + "resiliencyView". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2782,54 +2298,35 @@ async def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_redeploy_request( + _request = build_dedicated_host_groups_get_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2837,164 +2334,113 @@ async def _redeploy_initial( return deserialized # type: ignore @overload - async def begin_redeploy( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + host_group_name: str, + parameters: _models.DedicatedHostGroup, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_redeploy( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + host_group_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_redeploy( + async def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a + DedicatedHostGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "DedicatedHostGroup") - _request = build_virtual_machine_scale_sets_perform_maintenance_request( + _request = build_dedicated_host_groups_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3005,23 +2451,18 @@ async def _perform_maintenance_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3029,141 +2470,81 @@ async def _perform_maintenance_initial( return deserialized # type: ignore @overload - async def begin_perform_maintenance( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + host_group_name: str, + parameters: _models.DedicatedHostGroupUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_perform_maintenance( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + host_group_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_perform_maintenance( + async def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either + a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3177,19 +2558,19 @@ async def _update_instances_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") - _request = build_virtual_machine_scale_sets_update_instances_request( + _request = build_dedicated_host_groups_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3200,758 +2581,265 @@ async def _update_instances_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + @distributed_trace_async + async def delete(self, resource_group_name: str, host_group_name: str, **kwargs: Any) -> None: + """Delete a dedicated host group. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _approve_rolling_upgrade_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( + _request = build_dedicated_host_groups_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - return deserialized # type: ignore + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. + """ - @overload - async def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + models = _models - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @overload - async def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Image"]: + """Gets the list of Images in the subscription. Use nextLink property in the response to get the + next page of Images. Do this till nextLink is null to fetch all the Images. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace_async - async def begin_approve_rolling_upgrade( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_images_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response - :param resource_group_name: The name of the resource group. Required. + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Image"]: + """Gets the list of images under a resource group. Use nextLink property in the response to get + the next page of Images. Do this till nextLink is null to fetch all the Images. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._approve_rolling_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_images_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + response = pipeline_response.http_response - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoveryWalkResponse: - """Manual platform update domain walk to update virtual machines in a service fabric virtual - machine scale set. + async def get( + self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Image: + """Gets an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword platform_update_domain: The platform update domain for which a manual recovery walk is - requested. Required. - :paramtype platform_update_domain: int - :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual - machine scale set. Default value is None. - :paramtype zone: str - :keyword placement_group_id: The placement group id for which the manual recovery walk is - requested. Default value is None. - :paramtype placement_group_id: str - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse + :param image_name: The name of the image. Required. + :type image_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: Image or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.Image :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3966,15 +2854,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( + _request = build_images_get_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, subscription_id=self._config.subscription_id, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -3992,147 +2878,206 @@ async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + async def _create_or_update_initial( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Image") + + _request = build_images_create_or_update_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + @overload - async def convert_to_single_placement_group( + async def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, + image_name: str, + parameters: _models.Image, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + ) -> AsyncLROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def convert_to_single_placement_group( + async def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, + image_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + ) -> AsyncLROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + async def begin_create_or_update( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") - - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response + cls: ClsType[_models.Image] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + image_name=image_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Image].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _set_orchestration_service_state_initial( + async def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -4156,11 +3101,11 @@ async def _set_orchestration_service_state_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") + _json = self._serialize.body(parameters, "ImageUpdate") - _request = build_virtual_machine_scale_sets_set_orchestration_service_state_request( + _request = build_images_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4179,7 +3124,7 @@ async def _set_orchestration_service_state_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -4187,88 +3132,92 @@ async def _set_orchestration_service_state_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_set_orchestration_service_state( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.OrchestrationServiceStateInput, + image_name: str, + parameters: _models.ImageUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Changes ServiceState property for a given service. + ) -> AsyncLROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_set_orchestration_service_state( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, + image_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Changes ServiceState property for a given service. + ) -> AsyncLROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_set_orchestration_service_state( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Changes ServiceState property for a given service. + ) -> AsyncLROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Is either a - OrchestrationServiceStateInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4276,14 +3225,14 @@ async def begin_set_orchestration_service_state( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._set_orchestration_service_state_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -4295,12 +3244,126 @@ async def begin_set_orchestration_service_state( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Image].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_images_delete_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes an Image. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + image_name=image_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -4315,14 +3378,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore -class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long +class VirtualMachineImagesEdgeZoneOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models @@ -4335,14 +3398,20 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - async def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def list_publishers( + self, location: str, edge_zone: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4351,209 +3420,202 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_edge_zone_list_publishers_request( + location=location, + edge_zone=edge_zone, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. + @distributed_trace_async + async def list_offers( + self, location: str, edge_zone: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location, edge zone and + publisher. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_virtual_machine_images_edge_zone_list_offers_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. + async def list_skus( + self, location: str, edge_zone: str, publisher_name: str, offer: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and + offer. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_virtual_machine_images_edge_zone_list_skus_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - async def _update_initial( + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list( self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, edge zone, + publisher, offer, and SKU. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :keyword top: An integer value specifying the number of images to return that matches supplied + values. Default value is None. + :paramtype top: int + :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. + Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4562,205 +3624,68 @@ async def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_edge_zone_list_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. + async def get( + self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineImage: + """Gets a virtual machine image in an edge zone. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param version: A valid image SKU version. Required. + :type version: str + :return: VirtualMachineImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4773,12 +3698,15 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_edge_zone_get_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, + version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4786,109 +3714,57 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. + """ - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + models = _models - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. + async def list_by_edge_zone( + self, location: str, edge_zone: str, **kwargs: Any + ) -> _models.VmImagesInEdgeZoneListResult: + """Gets a list of all virtual machine image versions for the specified edge zone. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :return: VmImagesInEdgeZoneListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VmImagesInEdgeZoneListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4903,14 +3779,12 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_list_by_edge_zone_request( + location=location, + edge_zone=edge_zone, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -4928,35 +3802,23 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + deserialized = self._deserialize("VmImagesInEdgeZoneListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtension"]: - """Gets a list of all extensions in a VM scale set. + @distributed_trace_async + async def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image publishers for the specified Azure location. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4965,84 +3827,53 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _request = build_virtual_machine_images_list_publishers_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return pipeline_response + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return AsyncItemPaged(get_next, extract_data) + response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) -class VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. - """ + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - models = _models + return deserialized # type: ignore - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace_async + async def list_offers( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location and publisher. - async def _cancel_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5055,11 +3886,11 @@ async def _cancel_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_list_offers_request( + location=location, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5067,23 +3898,18 @@ async def _cancel_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5091,62 +3917,21 @@ async def _cancel_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_cancel( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Cancels the current virtual machine scale set rolling upgrade. + async def list_skus( + self, location: str, publisher_name: str, offer: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5159,11 +3944,12 @@ async def _start_os_upgrade_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_list_skus_request( + location=location, + publisher_name=publisher_name, + offer=offer, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5171,23 +3957,18 @@ async def _start_os_upgrade_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5195,64 +3976,39 @@ async def _start_os_upgrade_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all virtual machine scale set instances to the latest - available Platform Image OS version. Instances which are already running the latest available - OS version are not affected. + async def list( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, publisher, offer, + and SKU. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_os_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5265,35 +4021,35 @@ async def _start_extension_upgrade_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_list_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5301,73 +4057,23 @@ async def _start_extension_upgrade_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. + async def get( + self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineImage: + """Gets a virtual machine image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: RollingUpgradeStatusInfo or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param version: A valid image SKU version. Required. + :type version: str + :return: VirtualMachineImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5382,11 +4088,14 @@ async def get_latest( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_get_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5405,22 +4114,129 @@ async def get_latest( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RollingUpgradeStatusInfo", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace + def list_with_properties( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Union[str, _models.Expand], + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineImage"]: + """list_with_properties. -class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. "Properties" Required. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.Expand + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: An iterator like instance of either VirtualMachineImage or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineImagesWithPropertiesListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_images_list_with_properties_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineImagesWithPropertiesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LogAnalyticsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. + :attr:`log_analytics` attribute. """ models = _models @@ -5433,14 +4249,8 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - async def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any + async def _export_request_rate_by_interval_initial( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5460,16 +4270,13 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") + _json = self._serialize.body(parameters, "RequestRateByIntervalInput") - _request = build_virtual_machine_scale_set_vm_extensions_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + _request = build_log_analytics_export_request_rate_by_interval_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5488,7 +4295,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5496,112 +4303,86 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_export_request_rate_by_interval( self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, + location: str, + parameters: _models.RequestRateByIntervalInput, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + async def begin_export_request_rate_by_interval( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) + @distributed_trace_async + async def begin_export_request_rate_by_interval( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is + either a RequestRateByIntervalInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5609,17 +4390,14 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + raw_result = await self._export_request_rate_by_interval_initial( + location=location, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5631,36 +4409,33 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( + return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]( + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any + async def _export_throttled_requests_initial( + self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5680,16 +4455,13 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") + _json = self._serialize.body(parameters, "ThrottledRequestsInput") - _request = build_virtual_machine_scale_set_vm_extensions_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + _request = build_log_analytics_export_throttled_requests_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -5708,7 +4480,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5716,113 +4488,83 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_export_throttled_requests( self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, + location: str, + parameters: _models.ThrottledRequestsInput, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + async def begin_export_throttled_requests( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + async def begin_export_throttled_requests( + self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] + :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the + result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -5830,17 +4572,14 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + raw_result = await self._export_throttled_requests_initial( + location=location, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -5852,31 +4591,66 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( + return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]( + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_types( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image types. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5889,13 +4663,11 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + _request = build_virtual_machine_extension_images_list_types_request( + location=location, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5903,23 +4675,18 @@ async def _delete_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5927,90 +4694,33 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( + async def list_versions( self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, + location: str, + publisher_name: str, + type: str, *, - expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtension: - """The operation to get the VMSS VM extension. + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image versions. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :param type: Required. + :type type: str + :keyword filter: The filter to apply on the operation. Default value is None. + :paramtype filter: str + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6025,15 +4735,16 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + _request = build_virtual_machine_extension_images_list_versions_request( + location=location, + publisher_name=publisher_name, + type=type, subscription_id=self._config.subscription_id, - expand=expand, + filter=filter, + top=top, + orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -6051,7 +4762,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6059,27 +4770,21 @@ async def get( return deserialized # type: ignore @distributed_trace_async - async def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. + async def get( + self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineExtensionImage: + """Gets a virtual machine extension image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :param type: Required. + :type type: str + :param version: Required. + :type version: str + :return: VirtualMachineExtensionImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6094,14 +4799,14 @@ async def list( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + _request = build_virtual_machine_extension_images_get_request( + location=location, + publisher_name=publisher_name, + type=type, + version=version, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -6119,9 +4824,7 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize( - "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response - ) + deserialized = self._deserialize("VirtualMachineExtensionImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6129,14 +4832,14 @@ async def list( return deserialized # type: ignore -class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods +class VirtualMachineRunCommandsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. + :attr:`virtual_machine_run_commands` attribute. """ models = _models @@ -6149,16 +4852,97 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - async def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.RunCommandDocumentBase"]: + """Lists all available run commands for a subscription in a location. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either RunCommandDocumentBase or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_run_commands_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RunCommandListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: + """Gets specific run command for a subscription in a location. + + :param location: The name of Azure region. Required. + :type location: str + :param command_id: The command id. Required. + :type command_id: str + :return: RunCommandDocument or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6167,197 +4951,153 @@ async def _reimage_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_vm_reimage_input - else: - if vm_scale_set_vm_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") - else: - _json = None + cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_reimage_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + _request = build_virtual_machine_run_commands_get_request( + location=location, + command_id=command_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("RunCommandDocument", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. + @distributed_trace + def list_by_virtual_machine( + self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands of a Virtual Machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. + def prepare_request(next_link=None): + if not next_link: - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, None, {}) # type: ignore + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_by_virtual_machine( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineRunCommand: + """The operation to get the run command. - async def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6370,102 +5110,45 @@ async def _reimage_all_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_reimage_all_request( + _request = build_virtual_machine_run_commands_get_by_virtual_machine_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _approve_rolling_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6475,18 +5158,30 @@ async def _approve_rolling_upgrade_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_virtual_machine_run_commands_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -6500,7 +5195,7 @@ async def _approve_rolling_upgrade_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6509,7 +5204,9 @@ async def _approve_rolling_upgrade_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -6518,146 +5215,116 @@ async def _approve_rolling_upgrade_initial( return deserialized # type: ignore - @distributed_trace_async - async def begin_approve_rolling_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Approve upgrade on deferred rolling upgrade for OS disk on a VM scale set instance. + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: _models.VirtualMachineRunCommand, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._approve_rolling_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + Required. + :type run_command: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is + either a VirtualMachineRunCommand type or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deallocate_initial( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, + run_command=run_command, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -6666,34 +5333,37 @@ async def begin_deallocate( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -6714,18 +5384,16 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(run_command, (IOBase, bytes)): + _content = run_command else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - _request = build_virtual_machine_scale_set_vms_update_request( + _request = build_virtual_machine_run_commands_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -6743,7 +5411,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6751,10 +5419,14 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -6762,42 +5434,32 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, + vm_name: str, + run_command_name: str, + run_command: _models.VirtualMachineRunCommandUpdate, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -6805,42 +5467,32 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_name: str, + run_command_name: str, + run_command: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -6848,38 +5500,28 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is + either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -6887,18 +5529,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, + vm_name=vm_name, + run_command_name=run_command_name, + run_command=run_command, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -6910,36 +5550,37 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineScaleSetVM]( + return AsyncLROPoller[_models.VirtualMachineRunCommand]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _delete_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6955,12 +5596,11 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_delete_request( + _request = build_virtual_machine_run_commands_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -6983,34 +5623,31 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """Deletes a virtual machine from a VM scale set. + """The operation to delete the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword force_deletion: Optional parameter to force delete a virtual machine from a VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -7026,9 +5663,8 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - force_deletion=force_deletion, + vm_name=vm_name, + run_command_name=run_command_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -7043,7 +5679,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -7057,34 +5695,44 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVM: - """Gets a virtual machine from a VM scale set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual - machine. 'resiliencyView' will retrieve the instance view of the Virtual machine (if - applicable) and include 'resilientVMDeletionStatus' as part of it. Known values are: - "instanceView", "userData", and "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`usage` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: + """Gets, for the specified location, the current compute resource usage information as well as the + limits for compute resources under the subscription. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7093,58 +5741,177 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + _request = build_usage_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListUsagesResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: + """Gets all the VM scale sets under the specified subscription for the specified location. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def prepare_request(next_link=None): + if not next_link: - response = pipeline_response.http_response + _request = build_virtual_machine_scale_sets_list_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + async def get_next(next_link=None): + _request = prepare_request(next_link) - return deserialized # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - @distributed_trace_async - async def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMInstanceView: - """Gets the status of a virtual machine from a VM scale set. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: VirtualMachineScaleSetVMInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceView + @distributed_trace + def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this + till nextLink is null to fetch all the VM Scale Sets. + + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7153,79 +5920,76 @@ async def get_instance_view( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) + _request = build_virtual_machine_scale_sets_list_all_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_scale_set_vms_get_instance_view_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListWithLinkResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list( - self, - resource_group_name: str, - virtual_machine_scale_set_name: str, - *, - filter: Optional[str] = None, - select: Optional[str] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM scale sets under a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of + :return: An iterator like instance of either VirtualMachineScaleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7238,13 +6002,9 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_set_vms_list_request( + _request = build_virtual_machine_scale_sets_list_request( resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -7269,7 +6029,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -7292,15 +6052,30 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - async def _power_off_initial( + @distributed_trace_async + async def get( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, *, - skip_shutdown: bool = False, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> _models.VirtualMachineScaleSet: + """Display information about a virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the + UserData property of the VM scale set that was provided by the user during the VM scale set + Create/Update operation. "userData" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7313,15 +6088,80 @@ async def _power_off_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_sets_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_power_off_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSet") + + _request = build_virtual_machine_scale_sets_create_or_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7335,7 +6175,7 @@ async def _power_off_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7343,57 +6183,149 @@ async def _power_off_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: _models.VirtualMachineScaleSet, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_power_off( + async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], *, - skip_shutdown: bool = False, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. Additionally, this operation is not allowed on a virtual machine that is being - deallocated or already has been deallocated. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._power_off_initial( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -7402,27 +6334,40 @@ async def begin_power_off( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachineScaleSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _restart_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7432,18 +6377,31 @@ async def _restart_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_restart_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") + + _request = build_virtual_machine_scale_sets_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7457,7 +6415,7 @@ async def _restart_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7465,43 +6423,149 @@ async def _restart_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: _models.VirtualMachineScaleSetUpdate, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Restarts a virtual machine in a VM scale set. + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate or + IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -7510,27 +6574,38 @@ async def begin_restart( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachineScaleSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7546,11 +6621,11 @@ async def _start_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_start_request( + _request = build_virtual_machine_scale_sets_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -7565,7 +6640,7 @@ async def _start_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7573,25 +6648,32 @@ async def _start_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: - """Starts a virtual machine in a VM scale set. + """Deletes a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :keyword force_deletion: Optional parameter to force delete a VM scale set. (Feature in + Preview). Default value is None. + :paramtype force_deletion: bool :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -7605,10 +6687,10 @@ async def begin_start( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -7623,7 +6705,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -7637,8 +6721,12 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def _approve_rolling_upgrade_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7648,18 +6736,32 @@ async def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_redeploy_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7673,7 +6775,7 @@ async def _redeploy_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7681,44 +6783,116 @@ async def _redeploy_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and - powers it back on. + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._redeploy_initial( + raw_result = await self._approve_rolling_upgrade_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -7732,7 +6906,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -7746,31 +6922,83 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def retrieve_boot_diagnostics_data( + @overload + async def convert_to_single_placement_group( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, + content_type: str = "application/json", **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale - set. + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. + :type parameters: + ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def convert_to_single_placement_group( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def convert_to_single_placement_group( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult + :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a + VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. + :type parameters: + ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or + IO[bytes] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7781,19 +7009,29 @@ async def retrieve_boot_diagnostics_data( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") + + _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7810,15 +7048,17 @@ async def retrieve_boot_diagnostics_data( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async def _deallocate_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + hibernate: Optional[bool] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7828,18 +7068,33 @@ async def _perform_maintenance_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_deallocate_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + hibernate=hibernate, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7861,131 +7116,173 @@ async def _perform_maintenance_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + @overload + async def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + hibernate: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + @overload + async def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + hibernate: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def simulate_eviction( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. + async def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + hibernate: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: None or the result of cls(response) - :rtype: None + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._deallocate_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + hibernate=hibernate, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _attach_detach_data_disks_initial( + async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + *, + force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8006,16 +7303,16 @@ async def _attach_detach_data_disks_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( + _request = build_virtual_machine_scale_sets_delete_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, content_type=content_type, json=_json, @@ -8044,6 +7341,7 @@ async def _attach_detach_data_disks_initial( response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -8053,153 +7351,283 @@ async def _attach_detach_data_disks_initial( return deserialized # type: ignore @overload - async def begin_attach_detach_data_disks( + async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.AttachDetachDataDisksRequest, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, + force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_attach_detach_data_disks( + async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_instance_i_ds: IO[bytes], *, + force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: IO[bytes] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: IO[bytes] + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_attach_detach_data_disks( + async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + *, + force_deletion: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Deletes virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_instances_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + force_deletion=force_deletion, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long + self, + resource_group_name: str, + vm_scale_set_name: str, + *, + platform_update_domain: int, + zone: Optional[str] = None, + placement_group_id: Optional[str] = None, + **kwargs: Any + ) -> _models.RecoveryWalkResponse: + """Manual platform update domain walk to update virtual machines in a service fabric virtual + machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :keyword platform_update_domain: The platform update domain for which a manual recovery walk is + requested. Required. + :paramtype platform_update_domain: int + :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual + machine scale set. Default value is None. + :paramtype zone: str + :keyword placement_group_id: The placement group id for which the manual recovery walk is + requested. Default value is None. + :paramtype placement_group_id: str + :return: RecoveryWalkResponse or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + platform_update_domain=platform_update_domain, + zone=zone, + placement_group_id=placement_group_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_instance_view( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.VirtualMachineScaleSetInstanceView: + """Gets the status of a VM scale set instance. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Is either a AttachDetachDataDisksRequest type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: VirtualMachineScaleSetInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._attach_detach_data_disks_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_virtual_machine_scale_sets_get_instance_view_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.StorageProfile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.StorageProfile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - async def _run_command_initial( + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8220,15 +7648,14 @@ async def _run_command_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "RunCommandInput") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_virtual_machine_scale_set_vms_run_command_request( + _request = build_virtual_machine_scale_sets_update_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -8255,99 +7682,96 @@ async def _run_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_run_command( + async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_run_command( + async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_instance_i_ds: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_run_command( + async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> AsyncLROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -8355,16 +7779,15 @@ async def begin_run_command( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._run_command_initial( + raw_result = await self._update_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -8375,58 +7798,118 @@ async def begin_run_command( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_os_upgrade_history( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterable["_models.UpgradeOperationHistoricalStatusInfo"]: + # pylint: disable=line-too-long + """Gets list of OS upgrades on a VM scale set instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + async def get_next(next_link=None): + _request = prepare_request(next_link) -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - models = _models + return pipeline_response - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return AsyncItemPaged(get_next, extract_data) - async def _create_or_update_initial( + async def _perform_maintenance_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8447,15 +7930,17 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machine_extensions_create_or_update_request( + _request = build_virtual_machine_scale_sets_perform_maintenance_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -8474,7 +7959,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -8482,105 +7967,105 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_perform_maintenance( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> AsyncLROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def begin_perform_maintenance( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> AsyncLROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( + async def begin_perform_maintenance( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> AsyncLROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -8588,16 +8073,15 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._perform_maintenance_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -8608,35 +8092,34 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineExtension].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _update_initial( + async def _power_off_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8657,16 +8140,19 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machine_extensions_update_request( + _request = build_virtual_machine_scale_sets_power_off_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, json=_json, @@ -8684,7 +8170,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -8692,106 +8178,118 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, + skip_shutdown: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> AsyncLROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, + skip_shutdown: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> AsyncLROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> AsyncLROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -8799,16 +8297,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._power_off_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -8819,31 +8317,29 @@ async def begin_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineExtension].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any + async def _reapply_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8859,10 +8355,9 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_extensions_delete_request( + _request = build_virtual_machine_scale_sets_reapply_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -8878,7 +8373,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -8886,26 +8381,30 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any + async def begin_reapply( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete the extension. + """Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine + Instances. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -8919,10 +8418,9 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._reapply_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -8937,7 +8435,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -8951,90 +8451,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get( + async def _redeploy_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> _models.VirtualMachineExtension: - """The operation to get the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9043,146 +8466,198 @@ async def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_extensions_list_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_redeploy_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_redeploy( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. -class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - models = _models + @overload + async def begin_redeploy( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. + @distributed_trace_async + async def begin_redeploy( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param location: The location for which virtual machines under the subscription are queried. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_by_location_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _capture_initial( + async def _reimage_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -9203,14 +8678,17 @@ async def _capture_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_reimage_input else: - _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") + if vm_scale_set_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") + else: + _json = None - _request = build_virtual_machines_capture_request( + _request = build_virtual_machine_scale_sets_reimage_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -9237,94 +8715,100 @@ async def _capture_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_capture( + async def begin_reimage( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. + :type vm_scale_set_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_capture( + async def begin_reimage( self, resource_group_name: str, - vm_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. + :type vm_scale_set_reimage_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_capture( + async def begin_reimage( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a - VirtualMachineCaptureParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a + VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. + :type vm_scale_set_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9332,15 +8816,15 @@ async def begin_capture( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._capture_initial( + raw_result = await self._reimage_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -9351,11 +8835,9 @@ async def begin_capture( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -9366,24 +8848,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineCaptureResult].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineCaptureResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_or_update_initial( + async def _reimage_all_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -9404,17 +8881,18 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "VirtualMachine") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machines_create_or_update_request( + _request = build_virtual_machine_scale_sets_reimage_all_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -9432,7 +8910,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -9440,124 +8918,99 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create_or_update( + async def begin_reimage_all( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create_or_update( + async def begin_reimage_all( self, resource_group_name: str, - vm_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create_or_update( + async def begin_reimage_all( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> AsyncLROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9565,17 +9018,15 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._reimage_all_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -9586,37 +9037,32 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachine]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _update_initial( + async def _restart_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -9637,17 +9083,18 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "VirtualMachineUpdate") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machines_update_request( + _request = build_virtual_machine_scale_sets_restart_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -9665,7 +9112,7 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -9673,121 +9120,96 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a - VirtualMachineUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9795,17 +9217,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._restart_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -9816,31 +9236,33 @@ async def begin_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachine]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + async def _set_orchestration_service_state_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9850,18 +9272,29 @@ async def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") + + _request = build_virtual_machine_scale_sets_set_orchestration_service_state_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -9875,7 +9308,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -9883,50 +9316,111 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_set_orchestration_service_state( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: _models.OrchestrationServiceStateInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Changes ServiceState property for a given service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_orchestration_service_state( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Changes ServiceState property for a given service. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + async def begin_set_orchestration_service_state( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete a virtual machine. + """Changes ServiceState property for a given service. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword force_deletion: Optional parameter to force delete virtual machines. - NOTE: As of api-version 2024-11-01, we are rolling out a feature where if the forceDeletion - parameter is unspecified OR not explicitly set to false, AND all of the VM's attached disks - including the OS disk are marked with the delete option, then the VM will be force deleted. For - more details on how to configure delete options for a VM's resources, see `Delete a VM and - attached resources `_. To - avoid defaulting to force delete, ensure that the forceDeletion parameter is explicitly set to - false. This feature is expected to rollout by end of March 2025. Default value is None. - :paramtype force_deletion: bool + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Is either a + OrchestrationServiceStateInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput or + IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._set_orchestration_service_state_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - force_deletion=force_deletion, + vm_scale_set_name=vm_scale_set_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -9940,7 +9434,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -9954,133 +9450,30 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachine: - """Retrieves information about the model view or the instance view of a virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the virtual machine that is managed by the platform and - can change outside of control plane operations. 'UserData' retrieves the UserData property as - part of the VM model view that was provided by the user during the VM Create/Update operation. - Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - - _request = build_virtual_machines_get_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. + @distributed_trace + def list_skus( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineScaleSetSku"]: + """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM + instances allowed for each SKU. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: VirtualMachineInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) - async def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10089,102 +9482,66 @@ async def _convert_to_managed_disks_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_convert_to_managed_disks_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + def prepare_request(next_link=None): + if not next_link: - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + _request = build_virtual_machine_scale_sets_list_skus_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return deserialized # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - @distributed_trace_async - async def begin_convert_to_managed_disks( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be - stop-deallocated before invoking this operation. + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + async def get_next(next_link=None): + _request = prepare_request(next_link) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._convert_to_managed_disks_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + response = pipeline_response.http_response - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return pipeline_response - async def _deallocate_initial( - self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + return AsyncItemPaged(get_next, extract_data) + + async def _start_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10194,18 +9551,32 @@ async def _deallocate_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_deallocate_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_start_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - hibernate=hibernate, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -10227,44 +9598,114 @@ async def _deallocate_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_start( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts one or more virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts one or more virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_deallocate( - self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + async def begin_start( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: - """Shuts down the virtual machine and releases the compute resources. You are not billed for the - compute resources that this virtual machine uses. + """Starts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword hibernate: Optional parameter to hibernate a virtual machine. Default value is None. - :paramtype hibernate: bool + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._deallocate_initial( + raw_result = await self._start_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - hibernate=hibernate, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -10278,7 +9719,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -10292,85 +9735,33 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: - """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the - virtual machine before performing this operation. For Windows, please refer to `Create a - managed image of a generalized VM in Azure - `_. For - Linux, please refer to `How to create an image of a virtual machine or VHD - `_. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_generalize_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) +class VirtualMachinesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - response = pipeline_response.http_response + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. + """ - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + models = _models - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list( - self, - resource_group_name: str, - *, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachine"]: - # pylint: disable=line-too-long - """Lists all of the virtual machines in the specified resource group. Use the nextLink property in - the response to get the next page of virtual machines. + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachine"]: + """Gets all the virtual machines under the specified subscription for the specified location. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs + :param location: The name of Azure region. Required. + :type location: str :return: An iterator like instance of either VirtualMachine or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] @@ -10393,11 +9784,9 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machines_list_request( - resource_group_name=resource_group_name, + _request = build_virtual_machines_list_by_location_request( + location=location, subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -10545,26 +9934,40 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. + def list( + self, + resource_group_name: str, + *, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachine"]: + # pylint: disable=line-too-long + """Lists all of the virtual machines in the specified resource group. Use the nextLink property in + the response to get the next page of virtual machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :keyword filter: The system query option to filter VMs returned in the response. Allowed value + is 'virtualMachineScaleSet/id' eq + /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. + Default value is None. + :paramtype filter: str + :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching + run time status of all Virtual Machines, this can only be specified if a valid $filter option + is specified. "instanceView" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10577,10 +9980,11 @@ def list_available_sizes( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machines_list_available_sizes_request( + _request = build_virtual_machines_list_request( resource_group_name=resource_group_name, - vm_name=vm_name, subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -10605,11 +10009,11 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -10628,9 +10032,32 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - async def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vm_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.VirtualMachine: + """Retrieves information about the model view or the instance view of a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a + snapshot of the runtime properties of the virtual machine that is managed by the platform and + can change outside of control plane operations. 'UserData' retrieves the UserData property as + part of the VM model view that was provided by the user during the VM Create/Update operation. + Known values are: "instanceView", "userData", and "resiliencyView". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: VirtualMachine or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10643,105 +10070,47 @@ async def _power_off_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - _request = build_virtual_machines_power_off_request( + _request = build_virtual_machines_get_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, + expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def begin_power_off( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. NOTE: This - operation is not allowed on a virtual machine that is being deallocated or has already been - deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._power_off_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - skip_shutdown=skip_shutdown, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10750,17 +10119,31 @@ async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwarg } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_reapply_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachine") + + _request = build_virtual_machines_create_or_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -10774,7 +10157,7 @@ async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwarg response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -10782,38 +10165,152 @@ async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwarg map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachine, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """The operation to reapply a virtual machine's state. + async def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a + VirtualMachine type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._reapply_initial( + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -10822,26 +10319,41 @@ async def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10850,17 +10362,31 @@ async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwarg } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_restart_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineUpdate") + + _request = build_virtual_machines_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -10874,7 +10400,7 @@ async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwarg response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -10882,38 +10408,148 @@ async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwarg map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineUpdate, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """The operation to restart a virtual machine. + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a + VirtualMachineUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -10922,26 +10558,39 @@ async def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _delete_initial( + self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10956,10 +10605,11 @@ async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_start_request( + _request = build_virtual_machines_delete_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -10974,7 +10624,7 @@ async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -10982,21 +10632,32 @@ async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """The operation to start a virtual machine. + async def begin_delete( + self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str + :keyword force_deletion: Optional parameter to force delete virtual machines. Default value is + None. + :paramtype force_deletion: bool :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -11010,9 +10671,10 @@ async def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vm_name=vm_name, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -11027,7 +10689,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -11041,7 +10705,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _assess_patches_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11056,7 +10722,7 @@ async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_redeploy_request( + _request = build_virtual_machines_assess_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11082,35 +10748,45 @@ async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwar map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Shuts down the virtual machine, moves it to a new node, and powers it back on. + async def begin_assess_patches( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: + """Assess patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either VirtualMachineAssessPatchesResult or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAssessPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineAssessPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._redeploy_initial( + raw_result = await self._assess_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -11122,30 +10798,36 @@ async def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _reimage_initial( + async def _attach_detach_data_disks_initial( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -11169,12 +10851,9 @@ async def _reimage_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - if parameters is not None: - _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") - else: - _json = None + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - _request = build_virtual_machines_reimage_request( + _request = build_virtual_machines_attach_detach_data_disks_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11203,102 +10882,101 @@ async def _reimage_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_reimage( + async def begin_attach_detach_data_disks( self, resource_group_name: str, vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, + parameters: _models.AttachDetachDataDisksRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_reimage( + async def begin_attach_detach_data_disks( self, resource_group_name: str, vm_name: str, - parameters: Optional[IO[bytes]] = None, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_reimage( + async def begin_attach_detach_data_disks( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a - VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -11306,12 +10984,12 @@ async def begin_reimage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._attach_detach_data_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, @@ -11323,95 +11001,39 @@ async def begin_reimage( **kwargs ) await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_name: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - - _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - return deserialized # type: ignore + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.StorageProfile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.StorageProfile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any + async def _capture_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11421,17 +11043,29 @@ async def _perform_maintenance_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_perform_maintenance_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") + + _request = build_virtual_machines_capture_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -11453,40 +11087,120 @@ async def _perform_maintenance_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineCaptureParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_perform_maintenance( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to perform maintenance on a virtual machine. + async def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a + VirtualMachineCaptureParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineCaptureResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._perform_maintenance_initial( + raw_result = await self._capture_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -11495,76 +11209,32 @@ async def begin_perform_maintenance( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[None].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineCaptureResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def simulate_eviction(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: - """The operation to simulate the eviction of spot virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + return AsyncLROPoller[_models.VirtualMachineCaptureResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _assess_patches_initial( + async def _convert_to_managed_disks_initial( self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -11581,7 +11251,7 @@ async def _assess_patches_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_assess_patches_request( + _request = build_virtual_machines_convert_to_managed_disks_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11607,39 +11277,44 @@ async def _assess_patches_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_assess_patches( + async def begin_convert_to_managed_disks( self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. + ) -> AsyncLROPoller[None]: + """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be + stop-deallocated before invoking this operation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineAssessPatchesResult or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAssessPatchesResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineAssessPatchesResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._assess_patches_initial( + raw_result = await self._convert_to_managed_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -11651,11 +11326,9 @@ async def begin_assess_patches( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -11666,22 +11339,16 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _install_patches_initial( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _deallocate_initial( + self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11691,29 +11358,18 @@ async def _install_patches_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input - else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - - _request = build_virtual_machines_install_patches_request( + _request = build_virtual_machines_deallocate_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + hibernate=hibernate, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -11735,112 +11391,50 @@ async def _install_patches_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + async def begin_deallocate( + self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down the virtual machine and releases the compute resources. You are not billed for the + compute resources that this virtual machine uses. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] + :keyword hibernate: Optional parameter to hibernate a virtual machine. Default value is None. + :paramtype hibernate: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineInstallPatchesResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_patches_initial( + raw_result = await self._deallocate_initial( resource_group_name=resource_group_name, vm_name=vm_name, - install_patches_input=install_patches_input, + hibernate=hibernate, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -11849,11 +11443,9 @@ async def begin_install_patches( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -11864,21 +11456,75 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def generalize(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: + """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the + virtual machine before performing this operation. For Windows, please refer to `Create a + managed image of a generalized VM in Azure + `_. For + Linux, please refer to `How to create an image of a virtual machine or VHD + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_virtual_machines_generalize_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, ) + _request.url = self._client.format_url(_request.url) - async def _attach_detach_data_disks_initial( + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -11899,12 +11545,12 @@ async def _attach_detach_data_disks_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(install_patches_input, (IOBase, bytes)): + _content = install_patches_input else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - _request = build_virtual_machines_attach_detach_data_disks_request( + _request = build_virtual_machines_install_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11936,6 +11582,7 @@ async def _attach_detach_data_disks_initial( response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -11945,85 +11592,89 @@ async def _attach_detach_data_disks_initial( return deserialized # type: ignore @overload - async def begin_attach_detach_data_disks( + async def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: _models.AttachDetachDataDisksRequest, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult + or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_attach_detach_data_disks( + async def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: IO[bytes], + install_patches_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: IO[bytes] + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult + or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_attach_detach_data_disks( + async def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of - cls(response) + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult + or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -12031,15 +11682,15 @@ async def begin_attach_detach_data_disks( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineInstallPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._attach_detach_data_disks_initial( + raw_result = await self._install_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, + install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -12051,7 +11702,7 @@ async def begin_attach_detach_data_disks( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -12065,16 +11716,73 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.StorageProfile].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.StorageProfile]( + return AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @distributed_trace_async + async def instance_view( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> _models.VirtualMachineInstanceView: + """Retrieves information about the run-time state of a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: VirtualMachineInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) + + _request = build_virtual_machines_instance_view_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + async def _migrate_to_vm_scale_set_initial( self, resource_group_name: str, @@ -12137,10 +11845,14 @@ async def _migrate_to_vm_scale_set_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -12156,7 +11868,8 @@ async def begin_migrate_to_vm_scale_set( ) -> AsyncLROPoller[None]: """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str @@ -12183,7 +11896,8 @@ async def begin_migrate_to_vm_scale_set( ) -> AsyncLROPoller[None]: """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str @@ -12208,7 +11922,8 @@ async def begin_migrate_to_vm_scale_set( ) -> AsyncLROPoller[None]: """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str @@ -12249,7 +11964,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -12263,12 +11980,8 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any + async def _perform_maintenance_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12278,29 +11991,17 @@ async def _run_command_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( + _request = build_virtual_machines_perform_maintenance_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -12322,108 +12023,46 @@ async def _run_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on the VM. + async def begin_perform_maintenance( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to perform maintenance on a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._run_command_initial( + raw_result = await self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -12432,11 +12071,9 @@ async def begin_run_command( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -12447,57 +12084,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image. - - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage - :raises ~azure.core.exceptions.HttpResponseError: - """ + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _power_off_initial( + self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12510,134 +12107,111 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_get_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, + _request = build_virtual_machines_power_off_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def list( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, publisher, offer, - and SKU. + async def begin_power_off( + self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with + the same provisioned resources. You are still charged for this virtual machine. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._power_off_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + skip_shutdown=skip_shutdown, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - return deserialized # type: ignore + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async - async def list_offers( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location and publisher. + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12650,11 +12224,11 @@ async def list_offers( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, + _request = build_virtual_machines_reapply_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -12662,34 +12236,90 @@ async def list_offers( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location. + async def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """The operation to reapply a virtual machine's state. - :param location: The name of a supported Azure region. Required. - :type location: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reapply_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12702,10 +12332,11 @@ async def list_publishers(self, location: str, **kwargs: Any) -> List[_models.Vi _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_publishers_request( - location=location, + _request = build_virtual_machines_redeploy_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -12713,40 +12344,96 @@ async def list_publishers(self, location: str, **kwargs: Any) -> List[_models.Vi ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def list_skus( - self, location: str, publisher_name: str, offer: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. + async def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Shuts down the virtual machine, moves it to a new node, and powers it back on. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _reimage_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12755,55 +12442,205 @@ async def list_skus( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_skus_request( - location=location, - publisher_name=publisher_name, - offer=offer, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") + else: + _json = None + + _request = build_virtual_machines_reimage_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_reimage( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_reimage( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def list_by_edge_zone( - self, location: str, edge_zone: str, **kwargs: Any - ) -> _models.VmImagesInEdgeZoneListResult: - """Gets a list of all virtual machine image versions for the specified edge zone. + async def begin_reimage( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a + VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reimage_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :return: VmImagesInEdgeZoneListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VmImagesInEdgeZoneListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12816,11 +12653,11 @@ async def list_by_edge_zone( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_by_edge_zone_request( - location=location, - edge_zone=edge_zone, + _request = build_virtual_machines_restart_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -12828,172 +12665,111 @@ async def list_by_edge_zone( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_with_properties( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Union[str, _models.Expand], - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineImage"]: - """list_with_properties. + @distributed_trace_async + async def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """The operation to restart a virtual machine. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. "Properties" Required. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.Expand - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: An iterator like instance of either VirtualMachineImage or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImagesWithPropertiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_images_list_with_properties_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineImagesWithPropertiesListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - -class VirtualMachineImagesEdgeZoneOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def get( - self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image in an edge zone. + async def retrieve_boot_diagnostics_data( + self, + resource_group_name: str, + vm_name: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any + ) -> _models.RetrieveBootDiagnosticsDataResult: + """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs + with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated + with a default expiration duration of 120 minutes. Default value is None. + :paramtype sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13008,16 +12784,13 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_get_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, + _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, headers=_headers, params=_params, @@ -13035,52 +12808,20 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - @distributed_trace_async - async def list( + + async def _run_command_initial( self, - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, edge zone, - publisher, offer, and SKU. - - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: An integer value specifying the number of images to return that matches supplied - values. Default value is None. - :paramtype top: int - :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. - Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13089,61 +12830,204 @@ async def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RunCommandInput") + + _request = build_virtual_machines_run_command_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.RunCommandInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def list_offers( - self, location: str, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. + async def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._run_command_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def simulate_eviction(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> None: + """The operation to simulate the eviction of spot virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13158,12 +13042,11 @@ async def list_offers( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, + _request = build_virtual_machines_simulate_eviction_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -13178,31 +13061,14 @@ async def list_offers( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_publishers( - self, location: str, edge_zone: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. + if cls: + return cls(pipeline_response, None, {}) # type: ignore - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13215,11 +13081,11 @@ async def list_publishers( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, + _request = build_virtual_machines_start_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -13227,43 +13093,112 @@ async def list_publishers( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def list_skus( - self, location: str, edge_zone: str, publisher_name: str, offer: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and - offer. + async def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """The operation to start a virtual machine. - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineSize"]: + """Lists all available virtual machine sizes to which the specified virtual machine can be + resized. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13272,51 +13207,169 @@ async def list_skus( } error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machines_list_available_sizes_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineSize"]: + """This API is deprecated. Use `Resources Skus + `_. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :raises ~azure.core.exceptions.HttpResponseError: + """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_sizes_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) -class VirtualMachineExtensionImagesOperations: +class ProximityPlacementGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. + :attr:`proximity_placement_groups` attribute. """ models = _models @@ -13329,24 +13382,22 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace_async - async def get( - self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a subscription. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :param version: Required. - :type version: str - :return: VirtualMachineExtensionImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13355,56 +13406,79 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + _request = build_proximity_placement_groups_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_extension_images_get_request( - location=location, - publisher_name=publisher_name, - type=type, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("VirtualMachineExtensionImage", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a resource group. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13413,68 +13487,80 @@ async def list_types( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + _request = build_proximity_placement_groups_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_extension_images_list_types_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def list_versions( + async def get( self, - location: str, - publisher_name: str, - type: str, + resource_group_name: str, + proximity_placement_group_name: str, *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image versions. - - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :keyword filter: The filter to apply on the operation. Default value is None. - :paramtype filter: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] + ) -> _models.ProximityPlacementGroup: + """Retrieves information about a proximity placement group . + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :keyword include_colocation_status: includeColocationStatus=true enables fetching the + colocation status of all the resources in the proximity placement group. Default value is None. + :paramtype include_colocation_status: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13489,16 +13575,13 @@ async def list_versions( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_list_versions_request( - location=location, - publisher_name=publisher_name, - type=type, + _request = build_proximity_placement_groups_get_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, - filter=filter, - top=top, - orderby=orderby, + include_colocation_status=include_colocation_status, api_version=api_version, headers=_headers, params=_params, @@ -13516,57 +13599,38 @@ async def list_versions( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class AvailabilitySetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`availability_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @overload async def create_or_update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, + proximity_placement_group_name: str, + parameters: _models.ProximityPlacementGroup, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13574,25 +13638,27 @@ async def create_or_update( async def create_or_update( self, resource_group_name: str, - availability_set_name: str, + proximity_placement_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13600,21 +13666,22 @@ async def create_or_update( async def create_or_update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], + proximity_placement_group_name: str, + parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is + either a ProximityPlacementGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13630,7 +13697,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -13638,11 +13705,11 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "AvailabilitySet") + _json = self._serialize.body(parameters, "ProximityPlacementGroup") - _request = build_availability_sets_create_or_update_request( + _request = build_proximity_placement_groups_create_or_update_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -13660,11 +13727,11 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -13675,25 +13742,27 @@ async def create_or_update( async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, + proximity_placement_group_name: str, + parameters: _models.ProximityPlacementGroupUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13701,25 +13770,27 @@ async def update( async def update( self, resource_group_name: str, - availability_set_name: str, + proximity_placement_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13727,21 +13798,23 @@ async def update( async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + proximity_placement_group_name: str, + parameters: Union[_models.ProximityPlacementGroupUpdate, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is + either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or + IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13757,7 +13830,7 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -13765,11 +13838,11 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") - _request = build_availability_sets_update_request( + _request = build_proximity_placement_groups_update_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -13791,7 +13864,7 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -13799,13 +13872,14 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> None: - """Delete an availability set. + async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: + """Delete a proximity placement group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -13824,59 +13898,9 @@ async def delete(self, resource_group_name: str, availability_set_name: str, **k api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - _request = build_availability_sets_get_request( + _request = build_proximity_placement_groups_delete_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -13895,32 +13919,47 @@ async def get(self, resource_group_name: str, availability_set_name: str, **kwar map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore + +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. + def list_all(self, **kwargs: Any) -> AsyncIterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections in the subscription. Use nextLink property in the + response to get the next page of restore point collections. Do this till nextLink is not null + to fetch all the restore point collections. - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'virtualMachines/$ref'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13933,9 +13972,8 @@ def list_by_subscription( def prepare_request(next_link=None): if not next_link: - _request = build_availability_sets_list_by_subscription_request( + _request = build_restore_point_collections_list_all_request( subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -13960,7 +13998,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -13984,21 +14022,23 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.AvailabilitySet"]: - """Lists all availability sets in a resource group. + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections in a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14011,7 +14051,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - _request = build_availability_sets_list_request( + _request = build_restore_point_collections_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -14038,7 +14078,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -14061,28 +14101,158 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + *, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to get the restore point collection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :keyword expand: The expand expression to apply on the operation. If expand=restorePoints, + server will return all contained restore points in the restorePointCollection. "restorePoints" + Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + + _request = build_restore_point_collections_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollection, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14091,140 +14261,129 @@ def list_available_sizes( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_availability_sets_list_available_sizes_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePointCollection") + + _request = build_restore_point_collections_create_or_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @overload - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + async def update( self, resource_group_name: str, - availability_set_name: str, + restore_point_collection_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or + IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14240,7 +14399,7 @@ async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name- api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -14248,11 +14407,11 @@ async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name- if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( + _request = build_restore_point_collections_update_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -14270,27 +14429,168 @@ async def start_migration_to_virtual_machine_scale_set( # pylint: disable=name- response = pipeline_response.http_response - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_restore_point_collections_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the restore point collection. This operation will also delete all the + contained restore points. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. + """ + + models = _models - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace_async - async def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> None: - """Cancel the migration operation on an Availability Set. + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SshPublicKeyResource"]: + """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response + to get the next page of SSH public keys. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14299,115 +14599,80 @@ async def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=name } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_ssh_public_keys_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + return pipeline_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + return AsyncItemPaged(get_next, extract_data) - @overload - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SshPublicKeyResource"]: + """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in + the response to get the next page of SSH public keys. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :type resource_group_name: str + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace_async - async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14416,55 +14681,74 @@ async def validate_migration_to_virtual_machine_scale_set( # pylint: disable=na } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_ssh_public_keys_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + async def extract_data(pipeline_response): + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response = pipeline_response.http_response + return pipeline_response - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + return AsyncItemPaged(get_next, extract_data) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + @distributed_trace_async + async def get( + self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Retrieves information about an SSH public key. - async def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14473,54 +14757,34 @@ async def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") - else: - _json = None + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( + _request = build_ssh_public_keys_get_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14528,221 +14792,79 @@ async def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name return deserialized # type: ignore @overload - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._convert_to_virtual_machine_scale_set_initial( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( + async def create( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyResource, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def create( self, resource_group_name: str, - proximity_placement_group_name: str, + ssh_public_key_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( + async def create( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyResource, IO[bytes]], + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Is either a + SshPublicKeyResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14758,7 +14880,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -14766,11 +14888,11 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ProximityPlacementGroup") + _json = self._serialize.body(parameters, "SshPublicKeyResource") - _request = build_proximity_placement_groups_create_or_update_request( + _request = build_ssh_public_keys_create_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -14792,7 +14914,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14803,26 +14925,26 @@ async def create_or_update( async def update( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroupUpdate, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyUpdateResource, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -14830,26 +14952,26 @@ async def update( async def update( self, resource_group_name: str, - proximity_placement_group_name: str, + ssh_public_key_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -14857,22 +14979,23 @@ async def update( async def update( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: Union[_models.ProximityPlacementGroupUpdate, IO[bytes]], + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyUpdateResource, IO[bytes]], **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Is either a + SshPublicKeyUpdateResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14888,7 +15011,7 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -14896,11 +15019,11 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") + _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") - _request = build_proximity_placement_groups_update_request( + _request = build_ssh_public_keys_update_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -14922,7 +15045,7 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14930,13 +15053,14 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete(self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any) -> None: - """Delete a proximity placement group. + async def delete(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) -> None: + """Delete an SSH public key. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -14955,9 +15079,9 @@ async def delete(self, resource_group_name: str, proximity_placement_group_name: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_proximity_placement_groups_delete_request( + _request = build_ssh_public_keys_delete_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -14972,33 +15096,94 @@ async def delete(self, resource_group_name: str, proximity_placement_group_name: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async - async def get( + @overload + async def generate_key_pair( self, resource_group_name: str, - proximity_placement_group_name: str, + ssh_public_key_name: str, + parameters: Optional[_models.SshGenerateKeyPairInputParameters] = None, *, - include_colocation_status: Optional[str] = None, + content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Retrieves information about a proximity placement group . + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :keyword include_colocation_status: includeColocationStatus=true enables fetching the - colocation status of all the resources in the proximity placement group. Default value is None. - :paramtype include_colocation_status: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def generate_key_pair( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def generate_key_pair( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Is either a + SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or + IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15009,136 +15194,98 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - _request = build_proximity_placement_groups_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") + else: + _json = None + + _request = build_ssh_public_keys_generate_key_pair_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. - - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + response = pipeline_response.http_response - def prepare_request(next_link=None): - if not next_link: + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized # type: ignore - async def get_next(next_link=None): - _request = prepare_request(next_link) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. + """ - return pipeline_response + models = _models - return AsyncItemPaged(get_next, extract_data) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. + def list_by_capacity_reservation_group( + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CapacityReservation"]: + """Lists all of the capacity reservations in the specified capacity reservation group. Use the + nextLink property in the response to get the next page of capacity reservations. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :return: An iterator like instance of either CapacityReservation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15151,8 +15298,9 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - _request = build_proximity_placement_groups_list_by_resource_group_request( + _request = build_capacity_reservations_list_by_capacity_reservation_group_request( resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -15178,7 +15326,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -15201,106 +15349,86 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( + @distributed_trace_async + async def get( self, resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, + capacity_reservation_group_name: str, + capacity_reservation_name: str, *, - content_type: str = "application/json", + expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). + ) -> _models.CapacityReservation: + """The operation that retrieves information about the capacity reservation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a + snapshot of the runtime properties of the capacity reservation that is managed by the platform + and can change outside of control plane operations. "instanceView" Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) - @distributed_trace_async - async def create_or_update( + _request = build_capacity_reservations_get_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( self, resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15314,7 +15442,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -15322,11 +15450,12 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") + _json = self._serialize.body(parameters, "CapacityReservation") - _request = build_dedicated_host_groups_create_or_update_request( + _request = build_capacity_reservations_create_or_update_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -15337,7 +15466,8 @@ async def create_or_update( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -15345,89 +15475,180 @@ async def create_or_update( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def update( + async def begin_create_or_update( self, resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservation, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_create_or_update( self, resource_group_name: str, - host_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_create_or_update( self, resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Is either a + CapacityReservation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15441,7 +15662,7 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -15449,11 +15670,12 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") + _json = self._serialize.body(parameters, "CapacityReservationUpdate") - _request = build_dedicated_host_groups_update_request( + _request = build_capacity_reservations_update_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -15464,98 +15686,182 @@ async def update( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def delete(self, resource_group_name: str, host_group_name: str, **kwargs: Any) -> None: - """Delete a dedicated host group. + async def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: None or the result of cls(response) - :rtype: None + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Is either + a CapacityReservationUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_dedicated_host_groups_delete_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def get( + async def _delete_initial( self, resource_group_name: str, - host_group_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + capacity_reservation_group_name: str, + capacity_reservation_name: str, **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is - not supported for dedicated host group. Known values are: "instanceView", "userData", and - "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15568,133 +15874,156 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_host_groups_get_request( + _request = build_capacity_reservations_delete_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroup"]: - """Lists all of the dedicated host groups in the specified resource group. Use the nextLink - property in the response to get the next page of dedicated host groups. + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete a capacity reservation. This operation is allowed only when all the + associated resources are disassociated from the capacity reservation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - response = pipeline_response.http_response + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - return AsyncItemPaged(get_next, extract_data) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DedicatedHostGroup"]: - """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the - response to get the next page of dedicated host groups. + def list_by_host_group( + self, resource_group_name: str, host_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DedicatedHost"]: + """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink + property in the response to get the next page of dedicated hosts. - :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: An iterator like instance of either DedicatedHost or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15707,7 +16036,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Dedicate def prepare_request(next_link=None): if not next_link: - _request = build_dedicated_host_groups_list_by_subscription_request( + _request = build_dedicated_hosts_list_by_host_group_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -15733,7 +16064,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + deserialized = self._deserialize("DedicatedHostListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -15756,26 +16087,77 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.DedicatedHost: + """Retrieves information about a dedicated host. -class DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated host. 'UserData' is not supported for dedicated + host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - models = _models + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + _request = build_dedicated_hosts_get_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -15838,10 +16220,15 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -15858,11 +16245,12 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost @@ -15889,11 +16277,12 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: IO[bytes] @@ -15918,11 +16307,12 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost type or a IO[bytes] type. Required. @@ -15965,7 +16355,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -16042,10 +16434,14 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -16062,11 +16458,12 @@ async def begin_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate @@ -16093,11 +16490,12 @@ async def begin_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: IO[bytes] @@ -16122,11 +16520,12 @@ async def begin_update( ) -> AsyncLROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a DedicatedHostUpdate type or a IO[bytes] type. Required. @@ -16163,13 +16562,20 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -16229,10 +16635,15 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -16242,7 +16653,8 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Delete a dedicated host. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str @@ -16274,117 +16686,51 @@ async def begin_delete( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.DedicatedHost: - """Retrieves information about a dedicated host. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated host. 'UserData' is not supported for dedicated - host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHost"]: - """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink - property in the response to get the next page of dedicated hosts. + def list_available_sizes( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncIterable[str]: + """Lists all available dedicated host sizes to which the specified dedicated host can be resized. + NOTE: The dedicated host sizes provided can be used to only scale up the existing dedicated + host. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :return: An iterator like instance of either DedicatedHost or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16397,9 +16743,10 @@ def list_by_host_group( def prepare_request(next_link=None): if not next_link: - _request = build_dedicated_hosts_list_by_host_group_request( + _request = build_dedicated_hosts_list_available_sizes_request( resource_group_name=resource_group_name, host_group_name=host_group_name, + host_name=host_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -16425,7 +16772,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostListResult", pipeline_response) + deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -16448,6 +16795,125 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + async def _redeploy_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_dedicated_hosts_redeploy_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_redeploy( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Redeploy the dedicated host. The operation will complete successfully once the dedicated host + has migrated to a new node and is running. To determine the health of VMs deployed on the + dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please + refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more + details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + async def _restart_initial( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -16492,10 +16958,14 @@ async def _restart_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -16508,7 +16978,8 @@ async def begin_restart( after the restart check the Resource Health Center in the Azure Portal. Please refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str @@ -16545,7 +17016,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -16559,8 +17032,104 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _redeploy_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + *, + expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + **kwargs: Any + ) -> _models.RestorePoint: + """The operation to get the restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves + information about the run-time state of a restore point. "instanceView" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_restore_points_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16570,18 +17139,30 @@ async def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_hosts_redeploy_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePoint") + + _request = build_restore_points_create_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -16595,7 +17176,7 @@ async def _redeploy_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -16605,6 +17186,7 @@ async def _redeploy_initial( response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -16613,192 +17195,155 @@ async def _redeploy_initial( return deserialized # type: ignore - @distributed_trace_async - async def begin_redeploy( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Redeploy the dedicated host. The operation will complete successfully once the dedicated host - has migrated to a new node and is running. To determine the health of VMs deployed on the - dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please - refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more - details. + @overload + async def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: _models.RestorePoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._redeploy_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> AsyncIterable[str]: - """Lists all available dedicated host sizes to which the specified dedicated host can be resized. - NOTE: The dedicated host sizes provided can be used to only scale up the existing dedicated - host. + @overload + async def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[str] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_hosts_list_available_sizes_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. -class SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response - to get the next page of SSH public keys. - - :return: An iterator like instance of either SshPublicKeyResource or the result of + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Is either a + RestorePoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RestorePoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + async def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -16807,213 +17352,135 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SshPubli } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_ssh_public_keys_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_restore_points_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return pipeline_response + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the restore point. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_ssh_public_keys_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @overload - async def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ +class VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - async def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + models = _models - @distributed_trace_async - async def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Is either a - SshPublicKeyResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _start_extension_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17022,126 +17489,112 @@ async def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyResource") + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_create_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + @distributed_trace_async + async def begin_start_extension_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to + the latest available extension version. Instances which are already running the latest + extension versions are not affected. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_extension_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async - async def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyUpdateResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Is either a - SshPublicKeyUpdateResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _start_os_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17150,64 +17603,112 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_update_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def delete(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) -> None: - """Delete an SSH public key. + async def begin_start_os_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a rolling upgrade to move all virtual machine scale set instances to the latest + available Platform Image OS version. Instances which are already running the latest available + OS version are not affected. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: None or the result of cls(response) - :rtype: None + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_os_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _cancel_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17220,11 +17721,11 @@ async def delete(self, resource_group_name: str, ssh_public_key_name: str, **kwa _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_delete_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -17232,32 +17733,104 @@ async def delete(self, resource_group_name: str, ssh_public_key_name: str, **kwa ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def get( - self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Retrieves information about an SSH public key. + async def begin_cancel( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Cancels the current virtual machine scale set rolling upgrade. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cancel_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get_latest( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.RollingUpgradeStatusInfo: + """Gets the status of the latest virtual machine scale set rolling upgrade. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: RollingUpgradeStatusInfo or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -17272,11 +17845,11 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_get_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -17295,91 +17868,142 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + deserialized = self._deserialize("RollingUpgradeStatusInfo", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineScaleSetExtension"]: + """Gets a list of all extensions in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_set_extensions_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - return deserialized # type: ignore + async def get_next(next_link=None): + _request = prepare_request(next_link) - @overload - async def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[_models.SshGenerateKeyPairInputParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - async def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + return pipeline_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def generate_key_pair( + async def get( self, resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, + vm_scale_set_name: str, + vmss_extension_name: str, + *, + expand: Optional[str] = None, **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + ) -> _models.VirtualMachineScaleSetExtension: + """The operation to get the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Is either a - SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -17390,32 +18014,19 @@ async def generate_key_pair( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") - else: - _json = None + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_generate_key_pair_request( + _request = build_virtual_machine_scale_set_extensions_get_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -17432,36 +18043,20 @@ async def generate_key_pair( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - async def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -17481,14 +18076,15 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "Image") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") - _request = build_images_create_or_update_request( + _request = build_virtual_machine_scale_set_extensions_create_or_update_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -17515,10 +18111,15 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -17526,25 +18127,33 @@ async def _create_or_update_initial( async def begin_create_or_update( self, resource_group_name: str, - image_name: str, - parameters: _models.Image, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetExtension, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -17552,43 +18161,61 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - image_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Create or update an image. + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -17596,15 +18223,16 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -17616,33 +18244,36 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Image]( + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _update_initial( self, resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -17663,14 +18294,15 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "ImageUpdate") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - _request = build_images_update_request( + _request = build_virtual_machine_scale_set_extensions_update_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -17697,10 +18329,15 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -17708,25 +18345,33 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - image_name: str, - parameters: _models.ImageUpdate, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update an image. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -17734,25 +18379,32 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - image_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update an image. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -17760,21 +18412,29 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Image]: - """Update an image. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. + Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -17782,15 +18442,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -17802,29 +18463,33 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Image].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Image]( + return AsyncLROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + async def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17839,9 +18504,10 @@ async def _delete_initial(self, resource_group_name: str, image_name: str, **kwa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_images_delete_request( + _request = build_virtual_machine_scale_set_extensions_delete_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -17865,21 +18531,31 @@ async def _delete_initial(self, resource_group_name: str, image_name: str, **kwa map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes an Image. + async def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -17895,7 +18571,8 @@ async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -17905,100 +18582,87 @@ async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.Image - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) +class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = self._deserialize("Image", pipeline_response.http_response) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + models = _models - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Image"]: - """Gets the list of images under a resource group. Use nextLink property in the response to get - the next page of Images. Do this till nextLink is null to fetch all the Images. + def list( + self, + resource_group_name: str, + virtual_machine_scale_set_name: str, + *, + filter: Optional[str] = None, + select: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineScaleSetVM"]: + """Gets a list of all virtual machines in a VM scale sets. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] + :param virtual_machine_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type virtual_machine_scale_set_name: str + :keyword filter: The filter to apply to the operation. Allowed values are + 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied + eq true', 'properties/latestModelApplied eq false'. Default value is None. + :paramtype filter: str + :keyword select: The list parameters. Allowed values are 'instanceView', + 'instanceView/statuses'. Default value is None. + :paramtype select: str + :keyword expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -18011,9 +18675,13 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - _request = build_images_list_by_resource_group_request( + _request = build_virtual_machine_scale_set_vms_list_request( resource_group_name=resource_group_name, + virtual_machine_scale_set_name=virtual_machine_scale_set_name, subscription_id=self._config.subscription_id, + filter=filter, + select=select, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -18038,7 +18706,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -18061,21 +18729,34 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Image"]: - """Gets the list of Images in the subscription. Use nextLink property in the response to get the - next page of Images. Do this till nextLink is null to fetch all the Images. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVM: + """Gets a virtual machine from a VM scale set. - :return: An iterator like instance of either Image or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual + machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18084,160 +18765,53 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Image"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ + _request = build_virtual_machine_scale_set_vms_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - models = _models + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + response = pipeline_response.http_response - @overload - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) - @overload - async def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @distributed_trace_async - async def create_or_update( + async def _update_initial( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18251,7 +18825,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -18259,12 +18833,15 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "RestorePointCollection") + _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") - _request = build_restore_point_collections_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -18274,156 +18851,218 @@ async def create_or_update( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def update( + async def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.VirtualMachineScaleSetVM, *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. Is - either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. + Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVM or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualMachineScaleSetVM]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - async def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -18439,10 +19078,12 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_point_collections_delete_request( + _request = build_virtual_machine_scale_set_vms_delete_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -18465,24 +19106,40 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete the restore point collection. This operation will also delete all the - contained restore points. + """Deletes a virtual machine from a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the Restore Point Collection. Required. - :type restore_point_collection_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword force_deletion: Optional parameter to force delete a virtual machine from a VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -18498,7 +19155,9 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -18513,7 +19172,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -18527,30 +19188,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - *, - expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to get the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :keyword expand: The expand expression to apply on the operation. If expand=restorePoints, - server will return all contained restore points in the restorePointCollection. "restorePoints" - Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _approve_rolling_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18563,221 +19203,112 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_point_collections_get_request( + _request = build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.RestorePointCollection"]: - """Gets the list of restore point collections in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncIterable["_models.RestorePointCollection"]: - """Gets the list of restore point collections in the subscription. Use nextLink property in the - response to get the next page of restore point collections. Do this till nextLink is not null - to fetch all the restore point collections. - - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore + @distributed_trace_async + async def begin_approve_rolling_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Approve upgrade on deferred rolling upgrade for OS disk on a VM scale set instance. -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._approve_rolling_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_initial( + async def _attach_detach_data_disks_initial( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -18801,12 +19332,12 @@ async def _create_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "RestorePoint") + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - _request = build_restore_points_create_request( + _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -18825,7 +19356,7 @@ async def _create_initial( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -18833,99 +19364,111 @@ async def _create_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_create( + async def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: _models.RestorePoint, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.AttachDetachDataDisksRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_create( + async def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_create( + async def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Is either a AttachDetachDataDisksRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -18933,15 +19476,15 @@ async def begin_create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._attach_detach_data_disks_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, @@ -18954,30 +19497,32 @@ async def begin_create( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.RestorePoint].from_continuation_token( + return AsyncLROPoller[_models.StorageProfile].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.RestorePoint]( + return AsyncLROPoller[_models.StorageProfile]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + async def _deallocate_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -18993,10 +19538,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_points_delete_request( + _request = build_virtual_machine_scale_set_vms_deallocate_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -19012,7 +19557,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -19020,25 +19565,33 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + async def begin_deallocate( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete the restore point. + """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and + releases the compute resources it uses. You are not billed for the compute resources of this + virtual machine once it is deallocated. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the Restore Point Collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -19052,10 +19605,10 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._deallocate_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -19070,7 +19623,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -19085,28 +19640,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePoint: - """The operation to get the restore point. + async def get_instance_view( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> _models.VirtualMachineScaleSetVMInstanceView: + """Gets the status of a virtual machine from a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves - information about the run-time state of a restore point. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: VirtualMachineScaleSetVMInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19121,14 +19668,13 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) - _request = build_restore_points_get_request( + _request = build_virtual_machine_scale_set_vms_get_instance_view_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -19146,113 +19692,16 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroup, IO[bytes]], - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a - CapacityReservationGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _perform_maintenance_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19261,131 +19710,120 @@ async def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationGroup") + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. + @distributed_trace_async + async def begin_perform_maintenance( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Performs maintenance on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace_async - async def update( + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _power_off_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. Is - either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19394,67 +19832,128 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_update_request( + _request = build_virtual_machine_scale_set_vms_power_off_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def delete(self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any) -> None: - """The operation to delete a capacity reservation group. This operation is allowed only if all the - associated resources are disassociated from the reservation group and all capacity reservations - under the reservation group have also been deleted. Please refer to - https://aka.ms/CapacityReservation for more details. + async def begin_power_off( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached + and you are getting charged for the resources. Instead, use deallocate to release resources and + avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: None or the result of cls(response) - :rtype: None + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._power_off_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + skip_shutdown=skip_shutdown, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _redeploy_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19467,11 +19966,12 @@ async def delete(self, resource_group_name: str, capacity_reservation_group_name _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_delete_request( + _request = build_virtual_machine_scale_set_vms_redeploy_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -19479,46 +19979,105 @@ async def delete(self, resource_group_name: str, capacity_reservation_group_name ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_redeploy( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and + powers it back on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._redeploy_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get( + async def _reimage_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the capacity reservations under the capacity reservation group - which is a snapshot of the runtime properties of a capacity reservation that is managed by the - platform and can change outside of control plane operations. "instanceView" Default value is - None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19527,172 +20086,207 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_vm_reimage_input + else: + if vm_scale_set_vm_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") + else: + _json = None + + _request = build_virtual_machine_scale_set_vms_reimage_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_resource_group( + @overload + async def begin_reimage( self, resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroup"]: - """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink - property in the response to get the next page of capacity reservation groups. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) - specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are - associated to capacity reservation group in the response. Known values are: - "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Default value is None. + :type vm_scale_set_vm_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + @overload + async def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - return AsyncItemPaged(get_next, extract_data) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Default value is None. + :type vm_scale_set_vm_reimage_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def list_by_subscription( + @distributed_trace_async + async def begin_reimage( self, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroup"]: - """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in - the response to get the next page of capacity reservation groups. + ) -> AsyncLROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) - specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are - associated to capacity reservation group in the response. Known values are: - "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups - :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. - :code:`
` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation - group resources created in the subscription. :code:`
` 'SharedWithSubscription' enables - fetching Resource Ids for all capacity reservation group resources shared with the - subscription. :code:`
` 'All' enables fetching Resource Ids for all capacity reservation - group resources shared with the subscription and created in the subscription. Known values are: - "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. - :paramtype resource_ids_only: str or - ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value + is None. + :type vm_scale_set_vm_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reimage_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + async def _reimage_all_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19701,88 +20295,114 @@ def list_by_subscription( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_capacity_reservation_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - resource_ids_only=resource_ids_only, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_virtual_machine_scale_set_vms_reimage_all_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return pipeline_response + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized # type: ignore -class CapacityReservationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace_async + async def begin_reimage_all( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. + This operation is only supported for managed disks. - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - models = _models + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - async def _create_or_update_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservation, IO[bytes]], - **kwargs: Any + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _restart_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -19792,30 +20412,18 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservation") - - _request = build_capacity_reservations_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_restart_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -19829,132 +20437,57 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservation, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + async def begin_restart( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._restart_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -19963,35 +20496,105 @@ async def begin_create_or_update( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CapacityReservation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def retrieve_boot_diagnostics_data( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any + ) -> _models.RetrieveBootDiagnosticsDataResult: + """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs + with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated + with a default expiration duration of 120 minutes. Default value is None. + :paramtype sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, + api_version=api_version, + headers=_headers, + params=_params, ) + _request.url = self._client.format_url(_request.url) - async def _update_initial( + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _run_command_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -20015,12 +20618,12 @@ async def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "CapacityReservationUpdate") + _json = self._serialize.body(parameters, "RunCommandInput") - _request = build_capacity_reservations_update_request( + _request = build_virtual_machine_scale_set_vms_run_command_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -20047,99 +20650,107 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_update( + async def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. + ) -> AsyncLROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Is either - a CapacityReservationUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CapacityReservation or the result of + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -20147,15 +20758,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._run_command_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, @@ -20168,34 +20779,88 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.CapacityReservation].from_continuation_token( + return AsyncLROPoller[_models.RunCommandResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.CapacityReservation]( + return AsyncLROPoller[_models.RunCommandResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any + @distributed_trace_async + async def simulate_eviction( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> None: + """The operation to simulate the eviction of spot virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _start_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20211,10 +20876,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservations_delete_request( + _request = build_virtual_machine_scale_set_vms_start_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -20230,7 +20895,7 @@ async def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -20238,31 +20903,31 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any + async def begin_start( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete a capacity reservation. This operation is allowed only when all the - associated resources are disassociated from the capacity reservation. Please refer to - https://aka.ms/CapacityReservation for more details. + """Starts a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -20276,10 +20941,10 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._start_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -20289,50 +20954,145 @@ async def begin_delete( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: + """The operation to get all extensions of an instance in Virtual Machine Scaleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vm_extensions_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, *, - expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, + expand: Optional[str] = None, **kwargs: Any - ) -> _models.CapacityReservation: - """The operation that retrieves information about the capacity reservation. + ) -> _models.VirtualMachineScaleSetVMExtension: + """The operation to get the VMSS VM extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the capacity reservation that is managed by the platform - and can change outside of control plane operations. "instanceView" Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetVMExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20347,12 +21107,13 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - _request = build_capacity_reservations_get_request( + _request = build_virtual_machine_scale_set_vm_extensions_get_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -20372,35 +21133,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservation"]: - """Lists all of the capacity reservations in the specified capacity reservation group. Use the - nextLink property in the response to get the next page of capacity reservations. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - + async def _create_or_update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20409,83 +21157,227 @@ def list_by_capacity_reservation_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _request = build_virtual_machine_scale_set_vm_extensions_create_or_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return AsyncItemPaged(get_next, extract_data) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetVMExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + async def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20505,13 +21397,16 @@ async def _export_request_rate_by_interval_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "RequestRateByIntervalInput") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") - _request = build_log_analytics_export_request_rate_by_interval_request( - location=location, + _request = build_virtual_machine_scale_set_vm_extensions_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -20530,7 +21425,7 @@ async def _export_request_rate_by_interval_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -20538,79 +21433,120 @@ async def _export_request_rate_by_interval_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - async def begin_export_request_rate_by_interval( + async def begin_update( self, - location: str, - parameters: _models.RequestRateByIntervalInput, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_export_request_rate_by_interval( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: IO[bytes] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + async def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is - either a RequestRateByIntervalInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. + Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -20618,14 +21554,17 @@ async def begin_export_request_rate_by_interval( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._export_request_rate_by_interval_initial( - location=location, - parameters=parameters, + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -20636,34 +21575,38 @@ async def begin_export_request_rate_by_interval( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( + return AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any + async def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20673,28 +21616,19 @@ async def _export_throttled_requests_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ThrottledRequestsInput") - - _request = build_log_analytics_export_throttled_requests_request( - location=location, + _request = build_virtual_machine_scale_set_vm_extensions_delete_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -20708,7 +21642,7 @@ async def _export_throttled_requests_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -20716,93 +21650,52 @@ async def _export_throttled_requests_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_export_throttled_requests( - self, - location: str, - parameters: _models.ThrottledRequestsInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_export_throttled_requests( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_export_throttled_requests( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. + async def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Is either - a ThrottledRequestsInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] - :return: An instance of AsyncLROPoller that returns either LogAnalyticsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._export_throttled_requests_initial( - location=location, - parameters=parameters, + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -20811,41 +21704,36 @@ async def begin_export_throttled_requests( await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore -class VirtualMachineRunCommandsOperations: +class VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models @@ -20859,22 +21747,37 @@ def __init__(self, *args, **kwargs) -> None: self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands of an instance in Virtual Machine Scaleset. - :param location: The location upon which run commands is queried. Required. - :type location: str - :return: An iterator like instance of either RunCommandDocumentBase or the result of + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20887,9 +21790,12 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.RunComman def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_run_commands_list_request( - location=location, + _request = build_virtual_machine_scale_set_vm_run_commands_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -20914,7 +21820,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -20938,15 +21844,31 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. + async def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineRunCommand: + """The operation to get the VMSS VM run command. - :param location: The location upon which run commands is queried. Required. - :type location: str - :param command_id: The command id. Required. - :type command_id: str - :return: RunCommandDocument or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20961,12 +21883,15 @@ async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.Ru _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_get_request( - location=location, - command_id=command_id, + _request = build_virtual_machine_scale_set_vm_run_commands_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -20984,7 +21909,7 @@ async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.Ru map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunCommandDocument", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -20994,7 +21919,8 @@ async def get(self, location: str, command_id: str, **kwargs: Any) -> _models.Ru async def _create_or_update_initial( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any @@ -21022,9 +21948,10 @@ async def _create_or_update_initial( else: _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - _request = build_virtual_machine_run_commands_create_or_update_request( + _request = build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -21052,10 +21979,15 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -21063,21 +21995,24 @@ async def _create_or_update_initial( async def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommand, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. @@ -21096,27 +22031,30 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the result of cls(response) @@ -21129,19 +22067,22 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommand type or a IO[bytes] type. Required. @@ -21164,7 +22105,8 @@ async def begin_create_or_update( if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, @@ -21184,7 +22126,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -21203,7 +22147,8 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any @@ -21231,9 +22176,10 @@ async def _update_initial( else: _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - _request = build_virtual_machine_run_commands_update_request( + _request = build_virtual_machine_scale_set_vm_run_commands_update_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -21261,10 +22207,14 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -21272,24 +22222,26 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. + :param run_command: Resource create parameters. Required. :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -21305,27 +22257,29 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. + :param run_command: Resource create parameters. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the result of cls(response) @@ -21338,22 +22292,25 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. + :param run_command: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type + or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the @@ -21374,7 +22331,8 @@ async def begin_update( if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, @@ -21388,13 +22346,20 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -21411,7 +22376,7 @@ def get_long_running_output(pipeline_response): ) async def _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -21427,9 +22392,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_delete_request( + _request = build_virtual_machine_scale_set_vm_run_commands_delete_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -21454,25 +22420,32 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete the run command. + """The operation to delete the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be deleted. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] @@ -21489,7 +22462,8 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x, y, z: x, @@ -21505,7 +22479,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -21519,28 +22495,42 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace_async - async def get_by_virtual_machine( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineRunCommand: - """The operation to get the run command. + async def list( + self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.VirtualMachineExtensionsListResult: + """The operation to get all extensions of a Virtual Machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. Required. + :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -21555,12 +22545,11 @@ async def get_by_virtual_machine( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_get_by_virtual_machine_request( + _request = build_virtual_machine_extensions_list_request( resource_group_name=resource_group_name, vm_name=vm_name, - run_command_name=run_command_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -21580,37 +22569,38 @@ async def get_by_virtual_machine( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands of a Virtual Machine. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineExtension: + """The operation to get the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. Required. + :param vm_name: The name of the virtual machine. Required. :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21619,89 +22609,48 @@ def list_by_virtual_machine( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - return AsyncItemPaged(get_next, extract_data) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + _request = build_virtual_machine_extensions_get_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) -class VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ + response = pipeline_response.http_response - models = _models + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -21722,16 +22671,15 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") - _request = build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( + _request = build_virtual_machine_extensions_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -21758,10 +22706,15 @@ async def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -21769,34 +22722,32 @@ async def _create_or_update_initial( async def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: _models.VirtualMachineRunCommand, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtension, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -21804,34 +22755,32 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: IO[bytes], + vm_name: str, + vm_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: IO[bytes] + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -21839,29 +22788,28 @@ async def begin_create_or_update( async def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommand type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. + :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -21869,17 +22817,16 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - run_command=run_command, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -21891,35 +22838,36 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineRunCommand].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineRunCommand]( + return AsyncLROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -21940,16 +22888,15 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - _request = build_virtual_machine_scale_set_vm_run_commands_update_request( + _request = build_virtual_machine_extensions_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -21976,10 +22923,14 @@ async def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -21987,34 +22938,33 @@ async def _update_initial( async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: _models.VirtualMachineRunCommandUpdate, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -22022,65 +22972,61 @@ async def begin_update( async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: IO[bytes], + vm_name: str, + vm_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: IO[bytes] + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -22088,17 +23034,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - run_command=run_command, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -22110,30 +23055,37 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.VirtualMachineRunCommand].from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.VirtualMachineRunCommand]( + return AsyncLROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -22149,11 +23101,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_run_commands_delete_request( + _request = build_virtual_machine_extensions_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -22177,27 +23128,31 @@ async def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: - """The operation to delete the VMSS VM run command. + """The operation to delete the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -22213,9 +23168,8 @@ async def begin_delete( if cont_token is None: raw_result = await self._delete_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -22230,7 +23184,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -22243,171 +23199,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineRunCommand: - """The operation to get the VMSS VM run command. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vm_run_commands_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py index 3ca60bcc7b9a..095662596ac5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/__init__.py @@ -44,7 +44,6 @@ CapacityReservationProfile, CapacityReservationUpdate, CapacityReservationUtilization, - ComputeOperationListResult, ComputeOperationValue, ConvertToVirtualMachineScaleSetInput, DataDisk, @@ -75,6 +74,9 @@ DiskRestorePointInstanceView, DiskRestorePointReplicationStatus, EncryptionIdentity, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, EventGridAndResourceGraph, ExtendedLocation, HardwareProfile, @@ -112,6 +114,9 @@ OSImageNotificationProfile, OSProfile, OSProfileProvisioningData, + Operation, + OperationDisplay, + OperationListResult, OrchestrationServiceStateInput, OrchestrationServiceSummary, PatchInstallationDetail, @@ -133,8 +138,10 @@ ResilientVMCreationPolicy, ResilientVMDeletionPolicy, Resource, + ResourceAutoGenerated, ResourceSharingProfile, ResourceWithOptionalLocation, + ResourceWithOptionalLocationAutoGenerated, RestorePoint, RestorePointCollection, RestorePointCollectionListResult, @@ -144,8 +151,8 @@ RestorePointInstanceView, RestorePointSourceMetadata, RestorePointSourceVMDataDisk, - RestorePointSourceVMOSDisk, RestorePointSourceVMStorageProfile, + RestorePointSourceVmosDisk, RetrieveBootDiagnosticsDataResult, RollbackStatusInfo, RollingUpgradePolicy, @@ -184,8 +191,10 @@ SubResourceReadOnly, SubResourceWithColocationStatus, SystemData, + SystemDataAutoGenerated, TerminateNotificationProfile, ThrottledRequestsInput, + TrackedResource, UefiSettings, UpdateResource, UpgradeOperationHistoricalStatusInfo, @@ -195,6 +204,7 @@ Usage, UsageName, UserAssignedIdentitiesValue, + UserAssignedIdentitiesValueAutoGenerated, UserInitiatedReboot, UserInitiatedRedeploy, VMDiskSecurityProfile, @@ -303,6 +313,7 @@ ) from ._compute_management_client_enums import ( # type: ignore + ActionType, AllocationStrategy, AlternativeType, ArchitectureTypes, @@ -311,6 +322,7 @@ CapacityReservationGroupInstanceViewTypes, CapacityReservationInstanceViewTypes, ConsistencyModeTypes, + CreatedByType, DedicatedHostLicenseTypes, DeleteOptions, DiffDiskOptions, @@ -322,6 +334,7 @@ DomainNameLabelScopeTypes, ExecutionState, Expand, + ExpandType, ExpandTypeForListVMs, ExpandTypesForGetCapacityReservationGroups, ExpandTypesForGetVMScaleSets, @@ -351,6 +364,7 @@ OrchestrationServiceNames, OrchestrationServiceState, OrchestrationServiceStateAction, + Origin, PatchAssessmentState, PatchInstallationState, PatchOperationStatus, @@ -431,7 +445,6 @@ "CapacityReservationProfile", "CapacityReservationUpdate", "CapacityReservationUtilization", - "ComputeOperationListResult", "ComputeOperationValue", "ConvertToVirtualMachineScaleSetInput", "DataDisk", @@ -462,6 +475,9 @@ "DiskRestorePointInstanceView", "DiskRestorePointReplicationStatus", "EncryptionIdentity", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "EventGridAndResourceGraph", "ExtendedLocation", "HardwareProfile", @@ -499,6 +515,9 @@ "OSImageNotificationProfile", "OSProfile", "OSProfileProvisioningData", + "Operation", + "OperationDisplay", + "OperationListResult", "OrchestrationServiceStateInput", "OrchestrationServiceSummary", "PatchInstallationDetail", @@ -520,8 +539,10 @@ "ResilientVMCreationPolicy", "ResilientVMDeletionPolicy", "Resource", + "ResourceAutoGenerated", "ResourceSharingProfile", "ResourceWithOptionalLocation", + "ResourceWithOptionalLocationAutoGenerated", "RestorePoint", "RestorePointCollection", "RestorePointCollectionListResult", @@ -531,8 +552,8 @@ "RestorePointInstanceView", "RestorePointSourceMetadata", "RestorePointSourceVMDataDisk", - "RestorePointSourceVMOSDisk", "RestorePointSourceVMStorageProfile", + "RestorePointSourceVmosDisk", "RetrieveBootDiagnosticsDataResult", "RollbackStatusInfo", "RollingUpgradePolicy", @@ -571,8 +592,10 @@ "SubResourceReadOnly", "SubResourceWithColocationStatus", "SystemData", + "SystemDataAutoGenerated", "TerminateNotificationProfile", "ThrottledRequestsInput", + "TrackedResource", "UefiSettings", "UpdateResource", "UpgradeOperationHistoricalStatusInfo", @@ -582,6 +605,7 @@ "Usage", "UsageName", "UserAssignedIdentitiesValue", + "UserAssignedIdentitiesValueAutoGenerated", "UserInitiatedReboot", "UserInitiatedRedeploy", "VMDiskSecurityProfile", @@ -687,6 +711,7 @@ "WindowsConfiguration", "WindowsParameters", "WindowsVMGuestPatchAutomaticByPlatformSettings", + "ActionType", "AllocationStrategy", "AlternativeType", "ArchitectureTypes", @@ -695,6 +720,7 @@ "CapacityReservationGroupInstanceViewTypes", "CapacityReservationInstanceViewTypes", "ConsistencyModeTypes", + "CreatedByType", "DedicatedHostLicenseTypes", "DeleteOptions", "DiffDiskOptions", @@ -706,6 +732,7 @@ "DomainNameLabelScopeTypes", "ExecutionState", "Expand", + "ExpandType", "ExpandTypeForListVMs", "ExpandTypesForGetCapacityReservationGroups", "ExpandTypesForGetVMScaleSets", @@ -735,6 +762,7 @@ "OrchestrationServiceNames", "OrchestrationServiceState", "OrchestrationServiceStateAction", + "Origin", "PatchAssessmentState", "PatchInstallationState", "PatchOperationStatus", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py index 3720d04833a5..142a85929a34 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_compute_management_client_enums.py @@ -11,6 +11,12 @@ from azure.core import CaseInsensitiveEnumMeta +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + class AllocationStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the allocation strategy for the virtual machine scale set based on which the VMs will be allocated. @@ -78,6 +84,15 @@ class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): APPLICATION_CONSISTENT = "ApplicationConsistent" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. Possible values are: **None,** **Windows_Server_Hybrid,** **Windows_Server_Perpetual.** @@ -168,8 +183,8 @@ class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when - using this detach behavior. To force-detach a data disk update toBeDetached to 'true' along - with setting detachOption: 'ForceDetach'. + using this detach behavior. **This feature is still in preview**. To force-detach a data disk + update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. """ FORCE_DETACH = "ForceDetach" @@ -205,6 +220,12 @@ class Expand(str, Enum, metaclass=CaseInsensitiveEnumMeta): PROPERTIES = "Properties" +class ExpandType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExpandType.""" + + PROPERTIES = "Properties" + + class ExpandTypeForListVMs(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ExpandTypeForListVMs.""" @@ -293,8 +314,8 @@ class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Available from Api-Version 2019-07-01 onwards, it represents whether the specific - ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and + """Available from Api-Version 2017-03-30 onwards, it represents whether the specific + ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. """ @@ -346,8 +367,10 @@ class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEn class Mode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the mode that ProxyAgent will execute on. Warning: this property has been deprecated, - please specify 'mode' under particular hostendpoint setting. + """Specifies the mode that ProxyAgent will execute on if the feature is enabled. ProxyAgent will + start to audit or monitor but not enforce access control over requests to host endpoints in + Audit mode, while in Enforce mode it will enforce access control. The default value is Enforce + mode. """ AUDIT = "Audit" @@ -429,7 +452,6 @@ class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service.""" AUTOMATIC_REPAIRS = "AutomaticRepairs" - DUMMY_ORCHESTRATION_SERVICE_NAME = "DummyOrchestrationServiceName" class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -447,6 +469,16 @@ class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMe SUSPEND = "Suspend" +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch.""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py index 912c010949ad..cd34a97b7515 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/models/_models_py3.py @@ -8,19 +8,12 @@ # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from ... import _serialization -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore - if TYPE_CHECKING: from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class AdditionalCapabilities(_serialization.Model): @@ -526,28 +519,76 @@ def __init__( class Resource(_serialization.Model): - """The Resource model definition. + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -555,26 +596,24 @@ class Resource(_serialization.Model): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location self.tags = tags + self.location = location -class AvailabilitySet(Resource): +class AvailabilitySet(TrackedResource): """Specifies information about the availability set that the virtual machine should be assigned to. Virtual machines specified in the same availability set are allocated to different nodes to maximize availability. For more information about availability sets, see `Availability sets @@ -589,16 +628,21 @@ class AvailabilitySet(Resource): All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar sku: Sku of the availability set, only name is required to be set. See AvailabilitySetSkuTypes for possible set of values. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is @@ -629,6 +673,7 @@ class AvailabilitySet(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "statuses": {"readonly": True}, "virtual_machine_scale_set_migration_info": {"readonly": True}, @@ -638,8 +683,9 @@ class AvailabilitySet(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "platform_update_domain_count": {"key": "properties.platformUpdateDomainCount", "type": "int"}, "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, @@ -667,10 +713,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: Sku of the availability set, only name is required to be set. See AvailabilitySetSkuTypes for possible set of values. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is @@ -692,7 +738,7 @@ def __init__( :paramtype scheduled_events_policy: ~azure.mgmt.compute.v2024_11_01.models.ScheduledEventsPolicy """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.platform_update_domain_count = platform_update_domain_count self.platform_fault_domain_count = platform_fault_domain_count @@ -1031,34 +1077,35 @@ def __init__(self, **kwargs: Any) -> None: self.status = None -class CapacityReservation(Resource): +class CapacityReservation(TrackedResource): """Specifies information about the capacity reservation. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar sku: SKU of the resource for which capacity needs be reserved. The SKU name and capacity is required to be set. Currently VM Skus with the capability called 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. Required. :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :ivar zones: Availability Zone to use for this capacity reservation. The zone has to be single - value and also should be part for the list of zones specified during the capacity reservation - group creation. The zone can be assigned only during creation. If not provided, the reservation - supports only non-zonal deployments. If provided, enforces VM/VMSS using this capacity - reservation to be in same zone. + :ivar zones: The availability zones. :vartype zones: list[str] :ivar reservation_id: A unique id generated and assigned to the capacity reservation by the platform which does not change throughout the lifetime of the resource. @@ -1087,6 +1134,7 @@ class CapacityReservation(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "sku": {"required": True}, "reservation_id": {"readonly": True}, @@ -1102,8 +1150,9 @@ class CapacityReservation(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "zones": {"key": "zones", "type": "[str]"}, "reservation_id": {"key": "properties.reservationId", "type": "str"}, @@ -1125,24 +1174,20 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: SKU of the resource for which capacity needs be reserved. The SKU name and capacity is required to be set. Currently VM Skus with the capability called 'CapacityReservationSupported' set to true are supported. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values. Required. :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku - :keyword zones: Availability Zone to use for this capacity reservation. The zone has to be - single value and also should be part for the list of zones specified during the capacity - reservation group creation. The zone can be assigned only during creation. If not provided, the - reservation supports only non-zonal deployments. If provided, enforces VM/VMSS using this - capacity reservation to be in same zone. + :keyword zones: The availability zones. :paramtype zones: list[str] """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.zones = zones self.reservation_id = None @@ -1154,7 +1199,7 @@ def __init__( self.time_created = None -class CapacityReservationGroup(Resource): +class CapacityReservationGroup(TrackedResource): """Specifies information about the capacity reservation group that the capacity reservations should be assigned to. Currently, a capacity reservation can only be added to a capacity reservation group at creation time. An existing capacity reservation cannot be added or moved @@ -1164,20 +1209,22 @@ class CapacityReservationGroup(Resource): All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar zones: Availability Zones to use for this capacity reservation group. The zones can be - assigned only during creation. If not provided, the group supports only regional resources in - the region. If provided, enforces each capacity reservation in the group to be in one of the - zones. + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar zones: The availability zones. :vartype zones: list[str] :ivar capacity_reservations: A list of all capacity reservation resource ids that belong to capacity reservation group. @@ -1204,6 +1251,7 @@ class CapacityReservationGroup(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "capacity_reservations": {"readonly": True}, "virtual_machines_associated": {"readonly": True}, @@ -1214,8 +1262,9 @@ class CapacityReservationGroup(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "zones": {"key": "zones", "type": "[str]"}, "capacity_reservations": {"key": "properties.capacityReservations", "type": "[SubResourceReadOnly]"}, "virtual_machines_associated": {"key": "properties.virtualMachinesAssociated", "type": "[SubResourceReadOnly]"}, @@ -1233,14 +1282,11 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword zones: Availability Zones to use for this capacity reservation group. The zones can be - assigned only during creation. If not provided, the group supports only regional resources in - the region. If provided, enforces each capacity reservation in the group to be in one of the - zones. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword zones: The availability zones. :paramtype zones: list[str] :keyword sharing_profile: Specifies the settings to enable sharing across subscriptions for the capacity reservation group resource. Pls. keep in mind the capacity reservation group resource @@ -1250,7 +1296,7 @@ def __init__( more details. :paramtype sharing_profile: ~azure.mgmt.compute.v2024_11_01.models.ResourceSharingProfile """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.zones = zones self.capacity_reservations = None self.virtual_machines_associated = None @@ -1650,29 +1696,6 @@ def __init__(self, **kwargs: Any) -> None: self.virtual_machines_allocated = None -class ComputeOperationListResult(_serialization.Model): - """The List Compute Operation operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of compute operations. - :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.ComputeOperationValue] - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ComputeOperationValue]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - - class ComputeOperationValue(_serialization.Model): """Describes the properties of a Compute Operation value. @@ -1805,8 +1828,8 @@ class DataDisk(_serialization.Model): previous detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when - using this detach behavior. To force-detach a data disk update toBeDetached to 'true' along - with setting detachOption: 'ForceDetach'. "ForceDetach" + using this detach behavior. **This feature is still in preview**. To force-detach a data disk + update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. "ForceDetach" :vartype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion. Possible values are: **Delete.** If this value is used, the data disk is deleted when @@ -1906,8 +1929,8 @@ def __init__( previous detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when - using this detach behavior. To force-detach a data disk update toBeDetached to 'true' along - with setting detachOption: 'ForceDetach'. "ForceDetach" + using this detach behavior. **This feature is still in preview**. To force-detach a data disk + update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. "ForceDetach" :paramtype detach_option: str or ~azure.mgmt.compute.v2024_11_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion. Possible values are: **Delete.** If this value is used, the data disk is deleted when @@ -2083,23 +2106,28 @@ def __init__( self.detach_option = detach_option -class DedicatedHost(Resource): +class DedicatedHost(TrackedResource): """Specifies information about the Dedicated host. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar sku: SKU of the dedicated host for Hardware Generation and VM family. Only name is required to be set. List Microsoft.Compute SKUs for a list of possible values. Required. :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku @@ -2133,9 +2161,9 @@ class DedicatedHost(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "sku": {"required": True}, - "platform_fault_domain": {"minimum": 0}, "host_id": {"readonly": True}, "virtual_machines": {"readonly": True}, "provisioning_time": {"readonly": True}, @@ -2148,8 +2176,9 @@ class DedicatedHost(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "platform_fault_domain": {"key": "properties.platformFaultDomain", "type": "int"}, "auto_replace_on_failure": {"key": "properties.autoReplaceOnFailure", "type": "bool"}, @@ -2174,10 +2203,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: SKU of the dedicated host for Hardware Generation and VM family. Only name is required to be set. List Microsoft.Compute SKUs for a list of possible values. Required. :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku @@ -2194,7 +2223,7 @@ def __init__( :paramtype license_type: str or ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostLicenseTypes """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.platform_fault_domain = platform_fault_domain self.auto_replace_on_failure = auto_replace_on_failure @@ -2261,7 +2290,7 @@ def __init__( self.allocatable_v_ms = allocatable_v_ms -class DedicatedHostGroup(Resource): +class DedicatedHostGroup(TrackedResource): """Specifies information about the dedicated host group that the dedicated hosts should be assigned to. Currently, a dedicated host can only be added to a dedicated host group at creation time. An existing dedicated host cannot be added to another dedicated host group. @@ -2270,19 +2299,22 @@ class DedicatedHostGroup(Resource): All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar zones: Availability Zone to use for this host group. Only single zone is supported. The - zone can be assigned only during creation. If not provided, the group supports all zones in the - region. If provided, enforces each host in the group to be in the same zone. + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar zones: The availability zones. :vartype zones: list[str] :ivar platform_fault_domain_count: Number of fault domains that the host group can span. :vartype platform_fault_domain_count: int @@ -2306,6 +2338,7 @@ class DedicatedHostGroup(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "platform_fault_domain_count": {"minimum": 1}, "hosts": {"readonly": True}, @@ -2316,8 +2349,9 @@ class DedicatedHostGroup(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "zones": {"key": "zones", "type": "[str]"}, "platform_fault_domain_count": {"key": "properties.platformFaultDomainCount", "type": "int"}, "hosts": {"key": "properties.hosts", "type": "[SubResourceReadOnly]"}, @@ -2341,13 +2375,11 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword zones: Availability Zone to use for this host group. Only single zone is supported. - The zone can be assigned only during creation. If not provided, the group supports all zones in - the region. If provided, enforces each host in the group to be in the same zone. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword zones: The availability zones. :paramtype zones: list[str] :keyword platform_fault_domain_count: Number of fault domains that the host group can span. :paramtype platform_fault_domain_count: int @@ -2361,7 +2393,7 @@ def __init__( :paramtype additional_capabilities: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupPropertiesAdditionalCapabilities """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.zones = zones self.platform_fault_domain_count = platform_fault_domain_count self.hosts = None @@ -2680,19 +2712,25 @@ class DedicatedHostSizeListResult(_serialization.Model): :ivar value: The list of dedicated host sizes. :vartype value: list[str] + :ivar next_link: The link to the next page of items. + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[str]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List[str]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[List[str]] = None, next_link: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: The list of dedicated host sizes. :paramtype value: list[str] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class DedicatedHostUpdate(UpdateResource): @@ -2734,7 +2772,6 @@ class DedicatedHostUpdate(UpdateResource): """ _validation = { - "platform_fault_domain": {"minimum": 0}, "host_id": {"readonly": True}, "virtual_machines": {"readonly": True}, "provisioning_time": {"readonly": True}, @@ -3198,6 +3235,98 @@ def __init__(self, *, user_assigned_identity_resource_id: Optional[str] = None, self.user_assigned_identity_resource_id = user_assigned_identity_resource_id +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.compute.v2024_11_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.compute.v2024_11_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.compute.v2024_11_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.compute.v2024_11_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class EventGridAndResourceGraph(_serialization.Model): """Specifies eventGridAndResourceGraph related Scheduled Event related configurations. @@ -3424,7 +3553,7 @@ def __init__( self.in_vm_access_control_profile_reference_id = in_vm_access_control_profile_reference_id -class Image(Resource): +class Image(TrackedResource): """The source user image virtual hard disk. The virtual hard disk will be copied before being attached to the virtual machine. If SourceImage is provided, the destination virtual hard drive must not exist. @@ -3433,16 +3562,21 @@ class Image(Resource): All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar extended_location: The extended location of the Image. :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation :ivar source_virtual_machine: The source virtual machine from which Image is created. @@ -3464,6 +3598,7 @@ class Image(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, } @@ -3472,8 +3607,9 @@ class Image(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, "source_virtual_machine": {"key": "properties.sourceVirtualMachine", "type": "SubResource"}, "storage_profile": {"key": "properties.storageProfile", "type": "ImageStorageProfile"}, @@ -3493,10 +3629,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword extended_location: The extended location of the Image. :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation :keyword source_virtual_machine: The source virtual machine from which Image is created. @@ -3511,7 +3647,7 @@ def __init__( :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2024_11_01.models.HyperVGenerationTypes """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.extended_location = extended_location self.source_virtual_machine = source_virtual_machine self.storage_profile = storage_profile @@ -5057,13 +5193,133 @@ def __init__( self.network_interface_configurations = network_interface_configurations +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.compute.v2024_11_01.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.compute.v2024_11_01.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.compute.v2024_11_01.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.compute.v2024_11_01.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + class OrchestrationServiceStateInput(_serialization.Model): """The input for OrchestrationServiceState. All required parameters must be populated in order to send to server. - :ivar service_name: The name of the service. Required. Known values are: "AutomaticRepairs" and - "DummyOrchestrationServiceName". + :ivar service_name: The name of the service. Required. "AutomaticRepairs" :vartype service_name: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames :ivar action: The action to be performed. Required. Known values are: "Resume" and "Suspend". :vartype action: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateAction @@ -5087,8 +5343,7 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword service_name: The name of the service. Required. Known values are: "AutomaticRepairs" - and "DummyOrchestrationServiceName". + :keyword service_name: The name of the service. Required. "AutomaticRepairs" :paramtype service_name: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames :keyword action: The action to be performed. Required. Known values are: "Resume" and @@ -5106,8 +5361,7 @@ class OrchestrationServiceSummary(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Known values are: "AutomaticRepairs" and - "DummyOrchestrationServiceName". + :ivar service_name: The name of the service. "AutomaticRepairs" :vartype service_name: str or ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceNames :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", and "Suspended". @@ -5847,8 +6101,7 @@ class PriorityMixPolicy(_serialization.Model): """ _validation = { - "base_regular_priority_count": {"minimum": 0}, - "regular_priority_percentage_above_base": {"maximum": 100, "minimum": 0}, + "regular_priority_percentage_above_base": {"maximum": 100}, } _attribute_map = { @@ -5876,25 +6129,29 @@ def __init__( self.regular_priority_percentage_above_base = regular_priority_percentage_above_base -class ProximityPlacementGroup(Resource): +class ProximityPlacementGroup(TrackedResource): """Specifies information about the proximity placement group. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar zones: Specifies the Availability Zone where virtual machine, virtual machine scale set - or availability set associated with the proximity placement group can be created. + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar zones: The availability zones. :vartype zones: list[str] :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. Possible values are: **Standard** : Co-locate resources within an Azure region or Availability @@ -5923,6 +6180,7 @@ class ProximityPlacementGroup(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "virtual_machines": {"readonly": True}, "virtual_machine_scale_sets": {"readonly": True}, @@ -5933,8 +6191,9 @@ class ProximityPlacementGroup(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "zones": {"key": "zones", "type": "[str]"}, "proximity_placement_group_type": {"key": "properties.proximityPlacementGroupType", "type": "str"}, "virtual_machines": {"key": "properties.virtualMachines", "type": "[SubResourceWithColocationStatus]"}, @@ -5959,12 +6218,11 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword zones: Specifies the Availability Zone where virtual machine, virtual machine scale - set or availability set associated with the proximity placement group can be created. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword zones: The availability zones. :paramtype zones: list[str] :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. Possible values are: **Standard** : Co-locate resources within an Azure region or Availability @@ -5977,7 +6235,7 @@ def __init__( :paramtype intent: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupPropertiesIntent """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.zones = zones self.proximity_placement_group_type = proximity_placement_group_type self.virtual_machines = None @@ -6117,39 +6375,25 @@ def __init__( self.imds = imds -class ProxyResource(_serialization.Model): - """The resource model definition for an Azure Resource Manager proxy resource. It will not have +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - class PublicIPAddressSku(_serialization.Model): """Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. @@ -6450,6 +6694,55 @@ def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: self.enabled = enabled +class ResourceAutoGenerated(_serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + class ResourceSharingProfile(_serialization.Model): """ResourceSharingProfile. @@ -6520,17 +6813,68 @@ def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, s self.tags = tags -class RestorePoint(ProxyResource): - """Restore Point details. +class ResourceWithOptionalLocationAutoGenerated(_serialization.Model): # pylint: disable=name-too-long + """The Resource model definition with location property as optional. Variables are only populated by the server, and will be ignored when sending a request. + :ivar location: Resource location. + :vartype location: str :ivar id: Resource Id. :vartype id: str :ivar name: Resource name. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.location = location + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class RestorePoint(ProxyResource): + """Restore Point details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar exclude_disks: List of disk resource ids that the customer wishes to exclude from the restore point. If no disks are specified, all disks will be included. :vartype exclude_disks: list[~azure.mgmt.compute.v2024_11_01.models.ApiEntityReference] @@ -6557,6 +6901,7 @@ class RestorePoint(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "provisioning_state": {"readonly": True}, "instance_view": {"readonly": True}, } @@ -6565,6 +6910,7 @@ class RestorePoint(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "exclude_disks": {"key": "properties.excludeDisks", "type": "[ApiEntityReference]"}, "source_metadata": {"key": "properties.sourceMetadata", "type": "RestorePointSourceMetadata"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, @@ -6612,23 +6958,28 @@ def __init__( self.instance_view = None -class RestorePointCollection(Resource): +class RestorePointCollection(TrackedResource): """Create or update Restore Point collection parameters. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar source: The properties of the source resource that this restore point collection is created from. :vartype source: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties @@ -6645,6 +6996,7 @@ class RestorePointCollection(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, "restore_point_collection_id": {"readonly": True}, @@ -6655,8 +7007,9 @@ class RestorePointCollection(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "source": {"key": "properties.source", "type": "RestorePointCollectionSourceProperties"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "restore_point_collection_id": {"key": "properties.restorePointCollectionId", "type": "str"}, @@ -6672,16 +7025,16 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword source: The properties of the source resource that this restore point collection is created from. :paramtype source: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionSourceProperties """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.source = source self.provisioning_state = None self.restore_point_collection_id = None @@ -6691,27 +7044,29 @@ def __init__( class RestorePointCollectionListResult(_serialization.Model): """The List restore point collection operation response. - :ivar value: Gets the list of restore point collections. + All required parameters must be populated in order to send to server. + + :ivar value: Gets the list of restore point collections. Required. :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :ivar next_link: The uri to fetch the next page of RestorePointCollections. Call ListNext() with this to fetch the next page of RestorePointCollections. :vartype next_link: str """ + _validation = { + "value": {"required": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[RestorePointCollection]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.RestorePointCollection"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, value: List["_models.RestorePointCollection"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: Gets the list of restore point collections. + :keyword value: Gets the list of restore point collections. Required. :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :keyword next_link: The uri to fetch the next page of RestorePointCollections. Call ListNext() with this to fetch the next page of RestorePointCollections. @@ -7029,7 +7384,7 @@ def __init__( self.write_accelerator_enabled = None -class RestorePointSourceVMOSDisk(_serialization.Model): +class RestorePointSourceVmosDisk(_serialization.Model): """Describes an Operating System disk. Variables are only populated by the server, and will be ignored when sending a request. @@ -7103,10 +7458,11 @@ class RestorePointSourceVMStorageProfile(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar os_disk: Gets the OS disk of the VM captured at the time of the restore point creation. - :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMOSDisk - :ivar data_disks: Gets the data disks of the VM captured at the time of the restore point + :vartype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVmosDisk + :ivar data_disk_list: Gets the data disks of the VM captured at the time of the restore point creation. - :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMDataDisk] + :vartype data_disk_list: + list[~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMDataDisk] :ivar disk_controller_type: Gets the disk controller type of the VM captured at the time of the restore point creation. Known values are: "SCSI" and "NVMe". :vartype disk_controller_type: str or @@ -7118,30 +7474,30 @@ class RestorePointSourceVMStorageProfile(_serialization.Model): } _attribute_map = { - "os_disk": {"key": "osDisk", "type": "RestorePointSourceVMOSDisk"}, - "data_disks": {"key": "dataDisks", "type": "[RestorePointSourceVMDataDisk]"}, + "os_disk": {"key": "osDisk", "type": "RestorePointSourceVmosDisk"}, + "data_disk_list": {"key": "dataDisks", "type": "[RestorePointSourceVMDataDisk]"}, "disk_controller_type": {"key": "diskControllerType", "type": "str"}, } def __init__( self, *, - os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVmosDisk"] = None, + data_disk_list: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs: Any ) -> None: """ :keyword os_disk: Gets the OS disk of the VM captured at the time of the restore point creation. - :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMOSDisk - :keyword data_disks: Gets the data disks of the VM captured at the time of the restore point - creation. - :paramtype data_disks: + :paramtype os_disk: ~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVmosDisk + :keyword data_disk_list: Gets the data disks of the VM captured at the time of the restore + point creation. + :paramtype data_disk_list: list[~azure.mgmt.compute.v2024_11_01.models.RestorePointSourceVMDataDisk] """ super().__init__(**kwargs) self.os_disk = os_disk - self.data_disks = data_disks + self.data_disk_list = data_disk_list self.disk_controller_type = None @@ -7249,7 +7605,7 @@ class RollingUpgradePolicy(_serialization.Model): _validation = { "max_batch_instance_percent": {"maximum": 100, "minimum": 5}, "max_unhealthy_instance_percent": {"maximum": 100, "minimum": 5}, - "max_unhealthy_upgraded_instance_percent": {"maximum": 100, "minimum": 0}, + "max_unhealthy_upgraded_instance_percent": {"maximum": 100}, } _attribute_map = { @@ -7402,23 +7758,28 @@ def __init__(self, **kwargs: Any) -> None: self.last_action_time = None -class RollingUpgradeStatusInfo(Resource): +class RollingUpgradeStatusInfo(TrackedResource): """The status of the latest virtual machine scale set rolling upgrade. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar policy: The rolling upgrade policies applied for this upgrade. :vartype policy: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradePolicy :ivar running_status: Information about the current running state of the overall upgrade. @@ -7434,6 +7795,7 @@ class RollingUpgradeStatusInfo(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "policy": {"readonly": True}, "running_status": {"readonly": True}, @@ -7445,8 +7807,9 @@ class RollingUpgradeStatusInfo(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "policy": {"key": "properties.policy", "type": "RollingUpgradePolicy"}, "running_status": {"key": "properties.runningStatus", "type": "RollingUpgradeRunningStatus"}, "progress": {"key": "properties.progress", "type": "RollingUpgradeProgressInfo"}, @@ -7455,12 +7818,12 @@ class RollingUpgradeStatusInfo(Resource): def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.policy = None self.running_status = None self.progress = None @@ -7785,7 +8148,13 @@ class RunCommandParameterDefinition(_serialization.Model): } def __init__( - self, *, name: str, type: str, default_value: Optional[str] = None, required: bool = False, **kwargs: Any + self, + *, + name: str, + type: str, + default_value: Optional[str] = None, + required: Optional[bool] = None, + **kwargs: Any ) -> None: """ :keyword name: The run command parameter name. Required. @@ -8296,10 +8665,6 @@ class SkuProfileVMSize(_serialization.Model): :vartype rank: int """ - _validation = { - "rank": {"minimum": 0}, - } - _attribute_map = { "name": {"key": "name", "type": "str"}, "rank": {"key": "rank", "type": "int"}, @@ -8485,23 +8850,28 @@ def __init__( self.id = id -class SshPublicKeyResource(Resource): +class SshPublicKeyResource(TrackedResource): """Specifies information about the SSH public key. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar public_key: SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, @@ -8513,6 +8883,7 @@ class SshPublicKeyResource(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -8520,8 +8891,9 @@ class SshPublicKeyResource(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "public_key": {"key": "properties.publicKey", "type": "str"}, } @@ -8529,17 +8901,17 @@ def __init__( self, *, location: str, tags: Optional[Dict[str, str]] = None, public_key: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword public_key: SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format. :paramtype public_key: str """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.public_key = public_key @@ -8731,6 +9103,70 @@ def __init__( class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class SystemDataAutoGenerated(_serialization.Model): """The system meta data relating to this resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -9127,6 +9563,34 @@ def __init__(self, **kwargs: Any) -> None: self.client_id = None +class UserAssignedIdentitiesValueAutoGenerated(_serialization.Model): + """UserAssignedIdentitiesValueAutoGenerated. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + class UserInitiatedReboot(_serialization.Model): """Specifies Reboot related Scheduled Event related configurations. @@ -9284,23 +9748,28 @@ def __init__(self, *, uri: Optional[str] = None, **kwargs: Any) -> None: self.uri = uri -class VirtualMachine(Resource): +class VirtualMachine(TrackedResource): """Describes a Virtual Machine. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar plan: Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. In the Azure portal, find @@ -9311,7 +9780,7 @@ class VirtualMachine(Resource): :vartype resources: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :ivar identity: The identity of the virtual machine, if configured. :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity - :ivar zones: The virtual machine zones. + :ivar zones: The availability zones. :vartype zones: list[str] :ivar extended_location: The extended location of the Virtual Machine. :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation @@ -9319,9 +9788,11 @@ class VirtualMachine(Resource): the VM is part of the VMSS. This property is used by platform for internal resource group delete optimization. :vartype managed_by: str - :ivar etag: Etag is property returned in Create/Update/Get response of the VM, so that customer - can supply it in the header to ensure optimistic updates. - :vartype etag: str + :ivar e_tag: If eTag is provided in the response body, it may also be provided as a header per + the normal etag convention. Entity tags are used for comparing two or more entities from the + same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match + (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + :vartype e_tag: str :ivar placement: Placement section specifies the user-defined constraints for virtual machine hardware placement. This property cannot be changed once VM is provisioned. Minimum api-version: 2024-11-01. @@ -9443,10 +9914,11 @@ class VirtualMachine(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "resources": {"readonly": True}, "managed_by": {"readonly": True}, - "etag": {"readonly": True}, + "e_tag": {"readonly": True}, "provisioning_state": {"readonly": True}, "instance_view": {"readonly": True}, "vm_id": {"readonly": True}, @@ -9457,15 +9929,16 @@ class VirtualMachine(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "plan": {"key": "plan", "type": "Plan"}, "resources": {"key": "resources", "type": "[VirtualMachineExtension]"}, "identity": {"key": "identity", "type": "VirtualMachineIdentity"}, "zones": {"key": "zones", "type": "[str]"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, "managed_by": {"key": "managedBy", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, + "e_tag": {"key": "eTag", "type": "str"}, "placement": {"key": "placement", "type": "Placement"}, "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, "scheduled_events_policy": {"key": "properties.scheduledEventsPolicy", "type": "ScheduledEventsPolicy"}, @@ -9532,10 +10005,10 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword plan: Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. In the Azure portal, find @@ -9544,7 +10017,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan :keyword identity: The identity of the virtual machine, if configured. :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineIdentity - :keyword zones: The virtual machine zones. + :keyword zones: The availability zones. :paramtype zones: list[str] :keyword extended_location: The extended location of the Virtual Machine. :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation @@ -9656,14 +10129,14 @@ def __init__( # pylint: disable=too-many-locals to the VM/VMSS. :paramtype application_profile: ~azure.mgmt.compute.v2024_11_01.models.ApplicationProfile """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.plan = plan self.resources = None self.identity = identity self.zones = zones self.extended_location = extended_location self.managed_by = None - self.etag = None + self.e_tag = None self.placement = placement self.hardware_profile = hardware_profile self.scheduled_events_policy = scheduled_events_policy @@ -9859,9 +10332,9 @@ class VirtualMachineCaptureResult(SubResource): :ivar content_version: the version of the content. :vartype content_version: str :ivar parameters: parameters of the captured virtual machine. - :vartype parameters: JSON + :vartype parameters: any :ivar resources: a list of resource items of the captured virtual machine. - :vartype resources: list[JSON] + :vartype resources: list[any] """ _validation = { @@ -9891,21 +10364,28 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.resources = None -class VirtualMachineExtension(ResourceWithOptionalLocation): +class VirtualMachineExtension(TrackedResource): """Describes a Virtual Machine Extension. Variables are only populated by the server, and will be ignored when sending a request. - :ivar location: Resource location. - :vartype location: str - :ivar id: Resource Id. + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar force_update_tag: How the extension handler should be forced to update even if the extension configuration has not changed. :vartype force_update_tag: str @@ -9924,10 +10404,10 @@ class VirtualMachineExtension(ResourceWithOptionalLocation): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The virtual machine extension instance view. @@ -9950,15 +10430,18 @@ class VirtualMachineExtension(ResourceWithOptionalLocation): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, "provisioning_state": {"readonly": True}, } _attribute_map = { - "location": {"key": "location", "type": "str"}, "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "publisher": {"key": "properties.publisher", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, @@ -9980,7 +10463,7 @@ class VirtualMachineExtension(ResourceWithOptionalLocation): def __init__( self, *, - location: Optional[str] = None, + location: str, tags: Optional[Dict[str, str]] = None, force_update_tag: Optional[str] = None, publisher: Optional[str] = None, @@ -9988,8 +10471,8 @@ def __init__( type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, @@ -9997,10 +10480,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword force_update_tag: How the extension handler should be forced to update even if the extension configuration has not changed. :paramtype force_update_tag: str @@ -10019,10 +10502,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword instance_view: The virtual machine extension instance view. :paramtype instance_view: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView @@ -10038,7 +10521,7 @@ def __init__( needs to be provisioned. :paramtype provision_after_extensions: list[str] """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.force_update_tag = force_update_tag self.publisher = publisher self.type_properties_type = type_properties_type @@ -10093,23 +10576,28 @@ def __init__( self.status = status -class VirtualMachineExtensionImage(Resource): +class VirtualMachineExtensionImage(TrackedResource): """Describes a Virtual Machine Extension Image. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar operating_system: The operating system this extension supports. :vartype operating_system: str :ivar compute_role: The type of role (IaaS or PaaS) this extension supports. @@ -10129,6 +10617,7 @@ class VirtualMachineExtensionImage(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -10136,8 +10625,9 @@ class VirtualMachineExtensionImage(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "operating_system": {"key": "properties.operatingSystem", "type": "str"}, "compute_role": {"key": "properties.computeRole", "type": "str"}, "handler_schema": {"key": "properties.handlerSchema", "type": "str"}, @@ -10158,10 +10648,10 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword operating_system: The operating system this extension supports. :paramtype operating_system: str :keyword compute_role: The type of role (IaaS or PaaS) this extension supports. @@ -10176,7 +10666,7 @@ def __init__( :keyword supports_multiple_extensions: Whether the handler can support multiple extensions. :paramtype supports_multiple_extensions: bool """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.operating_system = operating_system self.compute_role = compute_role self.handler_schema = handler_schema @@ -10279,10 +10769,10 @@ class VirtualMachineExtensionUpdate(UpdateResource): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar suppress_failures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such as not connecting to the VM will not be suppressed regardless of this value). The default is false. @@ -10320,8 +10810,8 @@ def __init__( type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, **kwargs: Any @@ -10346,10 +10836,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword suppress_failures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such as not connecting to the VM will not be suppressed regardless of this value). The default is false. @@ -10541,7 +11031,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.PurchasePlan :ivar os_disk_image: Contains the os disk image information. :vartype os_disk_image: ~azure.mgmt.compute.v2024_11_01.models.OSDiskImage - :ivar data_disk_images: + :ivar data_disk_images: The list of data disk images information. :vartype data_disk_images: list[~azure.mgmt.compute.v2024_11_01.models.DataDiskImage] :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: @@ -10623,7 +11113,7 @@ def __init__( :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.PurchasePlan :keyword os_disk_image: Contains the os disk image information. :paramtype os_disk_image: ~azure.mgmt.compute.v2024_11_01.models.OSDiskImage - :keyword data_disk_images: + :keyword data_disk_images: The list of data disk images information. :paramtype data_disk_images: list[~azure.mgmt.compute.v2024_11_01.models.DataDiskImage] :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. @@ -10685,10 +11175,9 @@ def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, * class VirtualMachineImagesWithPropertiesListResult(_serialization.Model): # pylint: disable=name-too-long """The List Virtual Machine Images operation response. - :ivar value: The list of virtual machine images. + :ivar value: The VirtualMachineImage items on this page. :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] - :ivar next_link: The URI to fetch the next page of virtual machine images. Call ListNext() with - this URI to fetch the next page of virtual machine images. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -10705,10 +11194,9 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword value: The list of virtual machine images. + :keyword value: The VirtualMachineImage items on this page. :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] - :keyword next_link: The URI to fetch the next page of virtual machine images. Call ListNext() - with this URI to fetch the next page of virtual machine images. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -10723,7 +11211,7 @@ class VirtualMachineInstallPatchesParameters(_serialization.Model): :ivar maximum_duration: Specifies the maximum amount of time that the operation will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). - :vartype maximum_duration: str + :vartype maximum_duration: ~datetime.timedelta :ivar reboot_setting: Defines when it is acceptable to reboot a VM during a software update operation. Required. Known values are: "IfRequired", "Never", and "Always". :vartype reboot_setting: str or @@ -10741,7 +11229,7 @@ class VirtualMachineInstallPatchesParameters(_serialization.Model): } _attribute_map = { - "maximum_duration": {"key": "maximumDuration", "type": "str"}, + "maximum_duration": {"key": "maximumDuration", "type": "duration"}, "reboot_setting": {"key": "rebootSetting", "type": "str"}, "windows_parameters": {"key": "windowsParameters", "type": "WindowsParameters"}, "linux_parameters": {"key": "linuxParameters", "type": "LinuxParameters"}, @@ -10751,7 +11239,7 @@ def __init__( self, *, reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], - maximum_duration: Optional[str] = None, + maximum_duration: Optional[datetime.timedelta] = None, windows_parameters: Optional["_models.WindowsParameters"] = None, linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs: Any @@ -10759,7 +11247,7 @@ def __init__( """ :keyword maximum_duration: Specifies the maximum amount of time that the operation will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). - :paramtype maximum_duration: str + :paramtype maximum_duration: ~datetime.timedelta :keyword reboot_setting: Defines when it is acceptable to reboot a VM during a software update operation. Required. Known values are: "IfRequired", "Never", and "Always". :paramtype reboot_setting: str or @@ -10898,8 +11386,7 @@ class VirtualMachineInstanceView(_serialization.Model): :ivar extensions: The extensions information. :vartype extensions: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The application health status for the VM, provided through Application Health - Extension. + :ivar vm_health: The health status for the VM. :vartype vm_health: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineHealthStatus :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your @@ -11610,23 +12097,28 @@ def __init__( self.os_profile = os_profile -class VirtualMachineRunCommand(Resource): +class VirtualMachineRunCommand(TrackedResource): """Describes a Virtual Machine run command. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar source: The source of the run command script. :vartype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource :ivar parameters: The parameters used by the script. @@ -11692,6 +12184,7 @@ class VirtualMachineRunCommand(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, "instance_view": {"readonly": True}, @@ -11701,8 +12194,9 @@ class VirtualMachineRunCommand(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "source": {"key": "properties.source", "type": "VirtualMachineRunCommandScriptSource"}, "parameters": {"key": "properties.parameters", "type": "[RunCommandInputParameter]"}, "protected_parameters": {"key": "properties.protectedParameters", "type": "[RunCommandInputParameter]"}, @@ -11733,7 +12227,7 @@ def __init__( source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, parameters: Optional[List["_models.RunCommandInputParameter"]] = None, protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, + async_execution: Optional[bool] = None, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, timeout_in_seconds: Optional[int] = None, @@ -11741,14 +12235,14 @@ def __init__( error_blob_uri: Optional[str] = None, output_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, error_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, - treat_failure_as_deployment_failure: bool = False, + treat_failure_as_deployment_failure: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword source: The source of the run command script. :paramtype source: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandScriptSource :keyword parameters: The parameters used by the script. @@ -11798,7 +12292,7 @@ def __init__( error: https://aka.ms/runcommandmanaged#get-execution-status-and-results. :paramtype treat_failure_as_deployment_failure: bool """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.source = source self.parameters = parameters self.protected_parameters = protected_parameters @@ -12089,7 +12583,7 @@ def __init__( source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, parameters: Optional[List["_models.RunCommandInputParameter"]] = None, protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, - async_execution: bool = False, + async_execution: Optional[bool] = None, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, timeout_in_seconds: Optional[int] = None, @@ -12097,7 +12591,7 @@ def __init__( error_blob_uri: Optional[str] = None, output_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, error_blob_managed_identity: Optional["_models.RunCommandManagedIdentity"] = None, - treat_failure_as_deployment_failure: bool = False, + treat_failure_as_deployment_failure: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -12169,23 +12663,28 @@ def __init__( self.treat_failure_as_deployment_failure = treat_failure_as_deployment_failure -class VirtualMachineScaleSet(Resource): +class VirtualMachineScaleSet(TrackedResource): """Describes a Virtual Machine Scale Set. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar sku: The virtual machine scale set sku. :vartype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku :ivar plan: Specifies information about the marketplace image used to create the virtual @@ -12196,13 +12695,15 @@ class VirtualMachineScaleSet(Resource): :vartype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan :ivar identity: The identity of the virtual machine scale set, if configured. :vartype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity - :ivar zones: The virtual machine scale set zones. + :ivar zones: The availability zones. :vartype zones: list[str] :ivar extended_location: The extended location of the Virtual Machine Scale Set. :vartype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation - :ivar etag: Etag is property returned in Create/Update/Get response of the VMSS, so that - customer can supply it in the header to ensure optimistic updates. - :vartype etag: str + :ivar e_tag: If eTag is provided in the response body, it may also be provided as a header per + the normal etag convention. Entity tags are used for comparing two or more entities from the + same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match + (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + :vartype e_tag: str :ivar upgrade_policy: The upgrade policy. :vartype upgrade_policy: ~azure.mgmt.compute.v2024_11_01.models.UpgradePolicy :ivar scheduled_events_policy: The ScheduledEventsPolicy. @@ -12277,8 +12778,9 @@ class VirtualMachineScaleSet(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, - "etag": {"readonly": True}, + "e_tag": {"readonly": True}, "provisioning_state": {"readonly": True}, "unique_id": {"readonly": True}, "time_created": {"readonly": True}, @@ -12288,14 +12790,15 @@ class VirtualMachineScaleSet(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "plan": {"key": "plan", "type": "Plan"}, "identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"}, "zones": {"key": "zones", "type": "[str]"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "etag": {"key": "etag", "type": "str"}, + "e_tag": {"key": "eTag", "type": "str"}, "upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"}, "scheduled_events_policy": {"key": "properties.scheduledEventsPolicy", "type": "ScheduledEventsPolicy"}, "automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"}, @@ -12365,10 +12868,10 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword sku: The virtual machine scale set sku. :paramtype sku: ~azure.mgmt.compute.v2024_11_01.models.Sku :keyword plan: Specifies information about the marketplace image used to create the virtual @@ -12379,7 +12882,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype plan: ~azure.mgmt.compute.v2024_11_01.models.Plan :keyword identity: The identity of the virtual machine scale set, if configured. :paramtype identity: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetIdentity - :keyword zones: The virtual machine scale set zones. + :keyword zones: The availability zones. :paramtype zones: list[str] :keyword extended_location: The extended location of the Virtual Machine Scale Set. :paramtype extended_location: ~azure.mgmt.compute.v2024_11_01.models.ExtendedLocation @@ -12449,13 +12952,13 @@ def __init__( # pylint: disable=too-many-locals :keyword sku_profile: Specifies the sku profile for the virtual machine scale set. :paramtype sku_profile: ~azure.mgmt.compute.v2024_11_01.models.SkuProfile """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.plan = plan self.identity = identity self.zones = zones self.extended_location = extended_location - self.etag = None + self.e_tag = None self.upgrade_policy = upgrade_policy self.scheduled_events_policy = scheduled_events_policy self.automatic_repairs_policy = automatic_repairs_policy @@ -12621,18 +13124,17 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): :ivar id: Resource Id. :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str + :ivar vm_type: Resource type. + :vartype vm_type: str + :ivar vm_name: Resource name. + :vartype vm_name: str :ivar force_update_tag: If a value is provided and is different from the previous value, the extension handler will be forced to update even if the extension configuration has not changed. :vartype force_update_tag: str :ivar publisher: The name of the extension handler publisher. :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor @@ -12643,10 +13145,10 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar provision_after_extensions: Collection of extension names after which this extension @@ -12664,17 +13166,17 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): _validation = { "id": {"readonly": True}, - "type": {"readonly": True}, + "vm_type": {"readonly": True}, "provisioning_state": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, + "vm_type": {"key": "type", "type": "str"}, + "vm_name": {"key": "name", "type": "str"}, "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, @@ -12692,31 +13194,30 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): def __init__( self, *, - name: Optional[str] = None, + vm_name: Optional[str] = None, force_update_tag: Optional[str] = None, publisher: Optional[str] = None, - type_properties_type: Optional[str] = None, + type: Optional[str] = None, type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, provision_after_extensions: Optional[List[str]] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, **kwargs: Any ) -> None: """ - :keyword name: The name of the extension. - :paramtype name: str + :keyword vm_name: Resource name. + :paramtype vm_name: str :keyword force_update_tag: If a value is provided and is different from the previous value, the extension handler will be forced to update even if the extension configuration has not changed. :paramtype force_update_tag: str :keyword publisher: The name of the extension handler publisher. :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str :keyword type_handler_version: Specifies the version of the script handler. :paramtype type_handler_version: str :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor @@ -12727,10 +13228,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :paramtype provision_after_extensions: list[str] @@ -12744,11 +13245,11 @@ def __init__( ~azure.mgmt.compute.v2024_11_01.models.KeyVaultSecretReference """ super().__init__(**kwargs) - self.name = name - self.type = None + self.vm_type = None + self.vm_name = vm_name self.force_update_tag = force_update_tag self.publisher = publisher - self.type_properties_type = type_properties_type + self.type = type self.type_handler_version = type_handler_version self.auto_upgrade_minor_version = auto_upgrade_minor_version self.enable_automatic_upgrade = enable_automatic_upgrade @@ -12863,10 +13364,10 @@ class VirtualMachineScaleSetExtensionUpdate(SubResourceReadOnly): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar provision_after_extensions: Collection of extension names after which this extension @@ -12919,8 +13420,8 @@ def __init__( type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, provision_after_extensions: Optional[List[str]] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, @@ -12945,10 +13446,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword provision_after_extensions: Collection of extension names after which this extension needs to be provisioned. :paramtype provision_after_extensions: list[str] @@ -13684,10 +14185,9 @@ class VirtualMachineScaleSetNetworkProfile(_serialization.Model): :ivar network_interface_configurations: The list of network configurations. :vartype network_interface_configurations: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] - :ivar network_api_version: Specifies the Microsoft.Network API version used when creating + :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. For support of all network properties, use '2022-11-01'. Known - values are: "2020-11-01" and "2022-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion """ @@ -13716,10 +14216,9 @@ def __init__( :keyword network_interface_configurations: The list of network configurations. :paramtype network_interface_configurations: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetNetworkConfiguration] - :keyword network_api_version: Specifies the Microsoft.Network API version used when creating + :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. For support of all network properties, use '2022-11-01'. Known - values are: "2020-11-01" and "2022-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion """ super().__init__(**kwargs) @@ -14380,8 +14879,17 @@ class VirtualMachineScaleSetStorageProfile(_serialization.Model): `_. :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] - :ivar disk_controller_type: - :vartype disk_controller_type: str + :ivar disk_controller_type: Specifies the disk controller type configured for the VM and + VirtualMachineScaleSet. This property is only supported for virtual machines whose operating + system disk and VM sku supports Generation 2 + (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the + HyperVGenerations capability returned as part of VM sku capabilities in the response of + Microsoft.Compute SKUs api for the region contains V2 + (https://docs.microsoft.com/rest/api/compute/resourceskus/list). For more information about + Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes. Known + values are: "SCSI" and "NVMe". + :vartype disk_controller_type: str or + ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes """ _attribute_map = { @@ -14397,7 +14905,7 @@ def __init__( image_reference: Optional["_models.ImageReference"] = None, os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - disk_controller_type: Optional[str] = None, + disk_controller_type: Optional[Union[str, "_models.DiskControllerTypes"]] = None, **kwargs: Any ) -> None: """ @@ -14417,8 +14925,17 @@ def __init__( `_. :paramtype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] - :keyword disk_controller_type: - :paramtype disk_controller_type: str + :keyword disk_controller_type: Specifies the disk controller type configured for the VM and + VirtualMachineScaleSet. This property is only supported for virtual machines whose operating + system disk and VM sku supports Generation 2 + (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the + HyperVGenerations capability returned as part of VM sku capabilities in the response of + Microsoft.Compute SKUs api for the region contains V2 + (https://docs.microsoft.com/rest/api/compute/resourceskus/list). For more information about + Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes. Known + values are: "SCSI" and "NVMe". + :paramtype disk_controller_type: str or + ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes """ super().__init__(**kwargs) self.image_reference = image_reference @@ -14873,10 +15390,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(_serialization.Model): # pylin :ivar network_interface_configurations: The list of network configurations. :vartype network_interface_configurations: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - :ivar network_api_version: Specifies the Microsoft.Network API version used when creating + :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. For support of all network properties, use '2022-11-01'. Known - values are: "2020-11-01" and "2022-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion """ @@ -14907,10 +15423,9 @@ def __init__( :keyword network_interface_configurations: The list of network configurations. :paramtype network_interface_configurations: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] - :keyword network_api_version: Specifies the Microsoft.Network API version used when creating + :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. For support of all network properties, use '2022-11-01'. Known - values are: "2020-11-01" and "2022-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01" and "2022-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2024_11_01.models.NetworkApiVersion """ super().__init__(**kwargs) @@ -15140,8 +15655,17 @@ class VirtualMachineScaleSetUpdateStorageProfile(_serialization.Model): # pylin :ivar data_disks: The data disks. :vartype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] - :ivar disk_controller_type: - :vartype disk_controller_type: str + :ivar disk_controller_type: Specifies the disk controller type configured for the VM and + VirtualMachineScaleSet. This property is only supported for virtual machines whose operating + system disk and VM sku supports Generation 2 + (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the + HyperVGenerations capability returned as part of VM sku capabilities in the response of + Microsoft.Compute SKUs api for the region contains V2 + (https://docs.microsoft.com/rest/api/compute/resourceskus/list). For more information about + Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes. Known + values are: "SCSI" and "NVMe". + :vartype disk_controller_type: str or + ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes """ _attribute_map = { @@ -15157,7 +15681,7 @@ def __init__( image_reference: Optional["_models.ImageReference"] = None, os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, - disk_controller_type: Optional[str] = None, + disk_controller_type: Optional[Union[str, "_models.DiskControllerTypes"]] = None, **kwargs: Any ) -> None: """ @@ -15168,8 +15692,17 @@ def __init__( :keyword data_disks: The data disks. :paramtype data_disks: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetDataDisk] - :keyword disk_controller_type: - :paramtype disk_controller_type: str + :keyword disk_controller_type: Specifies the disk controller type configured for the VM and + VirtualMachineScaleSet. This property is only supported for virtual machines whose operating + system disk and VM sku supports Generation 2 + (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please check the + HyperVGenerations capability returned as part of VM sku capabilities in the response of + Microsoft.Compute SKUs api for the region contains V2 + (https://docs.microsoft.com/rest/api/compute/resourceskus/list). For more information about + Disk Controller Types supported please refer to https://aka.ms/azure-diskcontrollertypes. Known + values are: "SCSI" and "NVMe". + :paramtype disk_controller_type: str or + ~azure.mgmt.compute.v2024_11_01.models.DiskControllerTypes """ super().__init__(**kwargs) self.image_reference = image_reference @@ -15300,23 +15833,28 @@ def __init__( self.hardware_profile = hardware_profile -class VirtualMachineScaleSetVM(Resource): +class VirtualMachineScaleSetVM(TrackedResource): """Describes a virtual machine scale set virtual machine. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to server. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.compute.v2024_11_01.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str :ivar instance_id: The virtual machine instance ID. :vartype instance_id: str :ivar sku: The virtual machine SKU. @@ -15412,6 +15950,7 @@ class VirtualMachineScaleSetVM(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "instance_id": {"readonly": True}, "sku": {"readonly": True}, @@ -15430,8 +15969,9 @@ class VirtualMachineScaleSetVM(Resource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, "instance_id": {"key": "instanceId", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "plan": {"key": "plan", "type": "Plan"}, @@ -15486,10 +16026,10 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ - :keyword location: Resource location. Required. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str :keyword plan: Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. In the Azure portal, find @@ -15554,7 +16094,7 @@ def __init__( # pylint: disable=too-many-locals pass any secrets in here. Minimum api-version: 2021-03-01. :paramtype user_data: str """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.instance_id = None self.sku = None self.plan = plan @@ -15590,20 +16130,19 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): :ivar id: Resource Id. :vartype id: str - :ivar name: The name of the extension. - :vartype name: str - :ivar type: Resource type. - :vartype type: str :ivar location: The location of the extension. :vartype location: str + :ivar vm_type: Resource type. + :vartype vm_type: str + :ivar vm_name: Resource name. + :vartype vm_name: str :ivar force_update_tag: How the extension handler should be forced to update even if the extension configuration has not changed. :vartype force_update_tag: str :ivar publisher: The name of the extension handler publisher. :vartype publisher: str - :ivar type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :vartype type_properties_type: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor @@ -15614,10 +16153,10 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar instance_view: The virtual machine extension instance view. @@ -15638,19 +16177,19 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): _validation = { "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, + "vm_type": {"readonly": True}, + "vm_name": {"readonly": True}, "provisioning_state": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, "location": {"key": "location", "type": "str"}, + "vm_type": {"key": "type", "type": "str"}, + "vm_name": {"key": "name", "type": "str"}, "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "publisher": {"key": "properties.publisher", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, "type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"}, "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, @@ -15672,12 +16211,12 @@ def __init__( location: Optional[str] = None, force_update_tag: Optional[str] = None, publisher: Optional[str] = None, - type_properties_type: Optional[str] = None, + type: Optional[str] = None, type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, @@ -15692,9 +16231,8 @@ def __init__( :paramtype force_update_tag: str :keyword publisher: The name of the extension handler publisher. :paramtype publisher: str - :keyword type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :paramtype type_properties_type: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str :keyword type_handler_version: Specifies the version of the script handler. :paramtype type_handler_version: str :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor @@ -15705,10 +16243,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword instance_view: The virtual machine extension instance view. :paramtype instance_view: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView @@ -15725,12 +16263,12 @@ def __init__( :paramtype provision_after_extensions: list[str] """ super().__init__(**kwargs) - self.name = None - self.type = None self.location = location + self.vm_type = None + self.vm_name = None self.force_update_tag = force_update_tag self.publisher = publisher - self.type_properties_type = type_properties_type + self.type = type self.type_handler_version = type_handler_version self.auto_upgrade_minor_version = auto_upgrade_minor_version self.enable_automatic_upgrade = enable_automatic_upgrade @@ -15824,10 +16362,10 @@ class VirtualMachineScaleSetVMExtensionUpdate(SubResourceReadOnly): upgraded by the platform if there is a newer version of the extension available. :vartype enable_automatic_upgrade: bool :ivar settings: Json formatted public settings for the extension. - :vartype settings: JSON + :vartype settings: any :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :vartype protected_settings: JSON + :vartype protected_settings: any :ivar suppress_failures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such as not connecting to the VM will not be suppressed regardless of this value). The default is false. @@ -15872,8 +16410,8 @@ def __init__( type_handler_version: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, enable_automatic_upgrade: Optional[bool] = None, - settings: Optional[JSON] = None, - protected_settings: Optional[JSON] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional["_models.KeyVaultSecretReference"] = None, **kwargs: Any @@ -15897,10 +16435,10 @@ def __init__( upgraded by the platform if there is a newer version of the extension available. :paramtype enable_automatic_upgrade: bool :keyword settings: Json formatted public settings for the extension. - :paramtype settings: JSON + :paramtype settings: any :keyword protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :paramtype protected_settings: JSON + :paramtype protected_settings: any :keyword suppress_failures: Indicates whether failures stemming from the extension will be suppressed (Operational failures such as not connecting to the VM will not be suppressed regardless of this value). The default is false. @@ -15996,8 +16534,7 @@ class VirtualMachineScaleSetVMInstanceView(_serialization.Model): :ivar extensions: The extensions information. :vartype extensions: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionInstanceView] - :ivar vm_health: The application health status for the VM, provided through Application Health - Extension or Load Balancer Health Probes. + :ivar vm_health: The health status for the VM. :vartype vm_health: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineHealthStatus :ivar boot_diagnostics: Boot Diagnostics is a debugging feature which allows you to view Console Output and Screenshot to diagnose VM status. You can easily view the output of your @@ -16535,19 +17072,31 @@ class VirtualMachineSizeListResult(_serialization.Model): :ivar value: The list of virtual machine sizes. :vartype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :ivar next_link: The link to the next page of items. + :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[VirtualMachineSize]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + value: Optional[List["_models.VirtualMachineSize"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of virtual machine sizes. :paramtype value: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class VirtualMachineSoftwarePatchProperties(_serialization.Model): diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py index 5cc9a11e2341..6718c8ecb4f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/__init__.py @@ -13,31 +13,31 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import Operations # type: ignore +from ._operations import AvailabilitySetsOperations # type: ignore +from ._operations import CapacityReservationGroupsOperations # type: ignore +from ._operations import DedicatedHostGroupsOperations # type: ignore +from ._operations import ImagesOperations # type: ignore +from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore +from ._operations import VirtualMachineImagesOperations # type: ignore +from ._operations import LogAnalyticsOperations # type: ignore +from ._operations import VirtualMachineExtensionImagesOperations # type: ignore +from ._operations import VirtualMachineRunCommandsOperations # type: ignore from ._operations import UsageOperations # type: ignore -from ._operations import VirtualMachineSizesOperations # type: ignore from ._operations import VirtualMachineScaleSetsOperations # type: ignore -from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore -from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore -from ._operations import VirtualMachineExtensionsOperations # type: ignore from ._operations import VirtualMachinesOperations # type: ignore -from ._operations import VirtualMachineImagesOperations # type: ignore -from ._operations import VirtualMachineImagesEdgeZoneOperations # type: ignore -from ._operations import VirtualMachineExtensionImagesOperations # type: ignore -from ._operations import AvailabilitySetsOperations # type: ignore +from ._operations import VirtualMachineSizesOperations # type: ignore from ._operations import ProximityPlacementGroupsOperations # type: ignore -from ._operations import DedicatedHostGroupsOperations # type: ignore -from ._operations import DedicatedHostsOperations # type: ignore -from ._operations import SshPublicKeysOperations # type: ignore -from ._operations import ImagesOperations # type: ignore from ._operations import RestorePointCollectionsOperations # type: ignore -from ._operations import RestorePointsOperations # type: ignore -from ._operations import CapacityReservationGroupsOperations # type: ignore +from ._operations import SshPublicKeysOperations # type: ignore from ._operations import CapacityReservationsOperations # type: ignore -from ._operations import LogAnalyticsOperations # type: ignore -from ._operations import VirtualMachineRunCommandsOperations # type: ignore +from ._operations import DedicatedHostsOperations # type: ignore +from ._operations import RestorePointsOperations # type: ignore +from ._operations import VirtualMachineScaleSetRollingUpgradesOperations # type: ignore +from ._operations import VirtualMachineScaleSetExtensionsOperations # type: ignore +from ._operations import VirtualMachineScaleSetVMsOperations # type: ignore +from ._operations import VirtualMachineScaleSetVMExtensionsOperations # type: ignore from ._operations import VirtualMachineScaleSetVMRunCommandsOperations # type: ignore +from ._operations import VirtualMachineExtensionsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -45,31 +45,31 @@ __all__ = [ "Operations", + "AvailabilitySetsOperations", + "CapacityReservationGroupsOperations", + "DedicatedHostGroupsOperations", + "ImagesOperations", + "VirtualMachineImagesEdgeZoneOperations", + "VirtualMachineImagesOperations", + "LogAnalyticsOperations", + "VirtualMachineExtensionImagesOperations", + "VirtualMachineRunCommandsOperations", "UsageOperations", - "VirtualMachineSizesOperations", "VirtualMachineScaleSetsOperations", - "VirtualMachineScaleSetExtensionsOperations", - "VirtualMachineScaleSetRollingUpgradesOperations", - "VirtualMachineScaleSetVMExtensionsOperations", - "VirtualMachineScaleSetVMsOperations", - "VirtualMachineExtensionsOperations", "VirtualMachinesOperations", - "VirtualMachineImagesOperations", - "VirtualMachineImagesEdgeZoneOperations", - "VirtualMachineExtensionImagesOperations", - "AvailabilitySetsOperations", + "VirtualMachineSizesOperations", "ProximityPlacementGroupsOperations", - "DedicatedHostGroupsOperations", - "DedicatedHostsOperations", - "SshPublicKeysOperations", - "ImagesOperations", "RestorePointCollectionsOperations", - "RestorePointsOperations", - "CapacityReservationGroupsOperations", + "SshPublicKeysOperations", "CapacityReservationsOperations", - "LogAnalyticsOperations", - "VirtualMachineRunCommandsOperations", + "DedicatedHostsOperations", + "RestorePointsOperations", + "VirtualMachineScaleSetRollingUpgradesOperations", + "VirtualMachineScaleSetExtensionsOperations", + "VirtualMachineScaleSetVMsOperations", + "VirtualMachineScaleSetVMExtensionsOperations", "VirtualMachineScaleSetVMRunCommandsOperations", + "VirtualMachineExtensionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py index de3d9e4964eb..16080e3835ac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_01/operations/_operations.py @@ -63,7 +63,9 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_usage_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_availability_sets_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -71,18 +73,17 @@ def build_usage_list_request(location: str, subscription_id: str, **kwargs: Any) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -90,7 +91,7 @@ def build_usage_list_request(location: str, subscription_id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -99,11 +100,14 @@ def build_virtual_machine_sizes_list_request(location: str, subscription_id: str # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -117,8 +121,8 @@ def build_virtual_machine_sizes_list_request(location: str, subscription_id: str return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_list_by_location_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_availability_sets_get_request( + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -129,11 +133,14 @@ def build_virtual_machine_scale_sets_list_by_location_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -147,14 +154,8 @@ def build_virtual_machine_scale_sets_list_by_location_request( # pylint: disabl return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any +def build_availability_sets_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -166,12 +167,14 @@ def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -180,10 +183,6 @@ def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disabl _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -191,14 +190,8 @@ def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disabl return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any +def build_availability_sets_update_request( + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -210,12 +203,14 @@ def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -224,10 +219,6 @@ def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -235,13 +226,8 @@ def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any +def build_availability_sets_delete_request( + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -252,19 +238,19 @@ def build_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_deletion is not None: - _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -273,13 +259,8 @@ def build_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any +def build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -290,34 +271,29 @@ def build_virtual_machine_scale_sets_get_request( # pylint: disable=name-too-lo # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/cancelMigrationToVirtualMachineScaleSet", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - hibernate: Optional[bool] = None, - **kwargs: Any +def build_availability_sets_convert_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -329,19 +305,19 @@ def build_virtual_machine_scale_sets_deallocate_request( # pylint: disable=name # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/convertToVirtualMachineScaleSet", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if hibernate is not None: - _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -352,13 +328,8 @@ def build_virtual_machine_scale_sets_deallocate_request( # pylint: disable=name return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any +def build_availability_sets_start_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -370,19 +341,19 @@ def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/startMigrationToVirtualMachineScaleSet", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_deletion is not None: - _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -393,24 +364,27 @@ def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disabl return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/validateMigrationToVirtualMachineScaleSet", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -419,13 +393,15 @@ def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disab _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_list_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_availability_sets_list_available_sizes_request( # pylint: disable=name-too-long + resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -436,11 +412,14 @@ def build_virtual_machine_scale_sets_list_request( # pylint: disable=name-too-l # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -454,8 +433,12 @@ def build_virtual_machine_scale_sets_list_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any +def build_capacity_reservation_groups_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -465,16 +448,20 @@ def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-t # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" - ) + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if resource_ids_only is not None: + _params["resourceIdsOnly"] = _SERIALIZER.query("resource_ids_only", resource_ids_only, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -482,8 +469,12 @@ def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservation_groups_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -494,18 +485,21 @@ def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -513,8 +507,13 @@ def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_get_os_upgrade_history_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservation_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, + capacity_reservation_group_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -525,18 +524,24 @@ def build_virtual_machine_scale_sets_get_os_upgrade_history_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -544,13 +549,8 @@ def build_virtual_machine_scale_sets_get_os_upgrade_history_request( # pylint: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_power_off_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any +def build_capacity_reservation_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -562,19 +562,21 @@ def build_virtual_machine_scale_sets_power_off_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if skip_shutdown is not None: - _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -582,11 +584,11 @@ def build_virtual_machine_scale_sets_power_off_request( # pylint: disable=name- _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_restart_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservation_groups_update_request( # pylint: disable=name-too-long + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -598,12 +600,16 @@ def build_virtual_machine_scale_sets_restart_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -616,28 +622,31 @@ def build_virtual_machine_scale_sets_restart_request( # pylint: disable=name-to _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_start_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservation_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -646,15 +655,13 @@ def build_virtual_machine_scale_sets_start_request( # pylint: disable=name-too- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_reapply_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -663,14 +670,9 @@ def build_virtual_machine_scale_sets_reapply_request( # pylint: disable=name-to accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reapply", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -681,28 +683,28 @@ def build_virtual_machine_scale_sets_reapply_request( # pylint: disable=name-to # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -711,49 +713,53 @@ def build_virtual_machine_scale_sets_redeploy_request( # pylint: disable=name-t _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_get_request( + resource_group_name: str, + host_group_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_update_instances_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -765,12 +771,14 @@ def build_virtual_machine_scale_sets_update_instances_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -783,11 +791,11 @@ def build_virtual_machine_scale_sets_update_instances_request( # pylint: disabl _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_reimage_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_update_request( # pylint: disable=name-too-long + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -799,12 +807,14 @@ def build_virtual_machine_scale_sets_reimage_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -817,28 +827,29 @@ def build_virtual_machine_scale_sets_reimage_request( # pylint: disable=name-to _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_host_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -847,32 +858,22 @@ def build_virtual_machine_scale_sets_reimage_all_request( # pylint: disable=nam _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_images_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/approveRollingUpgrade", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -881,22 +882,13 @@ def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - subscription_id: str, - *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any +def build_images_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -907,66 +899,63 @@ def build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_upda # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["platformUpdateDomain"] = _SERIALIZER.query("platform_update_domain", platform_update_domain, "int") - if zone is not None: - _params["zone"] = _SERIALIZER.query("zone", zone, "str") - if placement_group_id is not None: - _params["placementGroupId"] = _SERIALIZER.query("placement_group_id", placement_group_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_convert_to_single_placement_group_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_images_get_request( + resource_group_name: str, image_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "imageName": _SERIALIZER.url("image_name", image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_sets_set_orchestration_service_state_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_images_create_or_update_request( + resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -978,12 +967,14 @@ def build_virtual_machine_scale_sets_set_orchestration_service_state_request( # # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "imageName": _SERIALIZER.url("image_name", image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -996,11 +987,11 @@ def build_virtual_machine_scale_sets_set_orchestration_service_state_request( # _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_extensions_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +def build_images_update_request( + resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1012,13 +1003,14 @@ def build_virtual_machine_scale_set_extensions_create_or_update_request( # pyli # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "imageName": _SERIALIZER.url("image_name", image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1031,29 +1023,29 @@ def build_virtual_machine_scale_set_extensions_create_or_update_request( # pyli _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_extensions_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +def build_images_delete_request( + resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "imageName": _SERIALIZER.url("image_name", image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1062,15 +1054,13 @@ def build_virtual_machine_scale_set_extensions_update_request( # pylint: disabl _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_edge_zone_list_publishers_request( # pylint: disable=name-too-long + location: str, edge_zone: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1081,13 +1071,12 @@ def build_virtual_machine_scale_set_extensions_delete_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1098,17 +1087,11 @@ def build_virtual_machine_scale_set_extensions_delete_request( # pylint: disabl # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_extensions_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_images_edge_zone_list_offers_request( # pylint: disable=name-too-long + location: str, edge_zone: str, publisher_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1119,20 +1102,18 @@ def build_virtual_machine_scale_set_extensions_get_request( # pylint: disable=n # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1141,8 +1122,8 @@ def build_virtual_machine_scale_set_extensions_get_request( # pylint: disable=n return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_extensions_list_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_edge_zone_list_skus_request( # pylint: disable=name-too-long + location: str, edge_zone: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1153,12 +1134,14 @@ def build_virtual_machine_scale_set_extensions_list_request( # pylint: disable= # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1172,8 +1155,18 @@ def build_virtual_machine_scale_set_extensions_list_request( # pylint: disable= return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_rolling_upgrades_cancel_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_edge_zone_list_request( # pylint: disable=name-too-long + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, + subscription_id: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1184,27 +1177,43 @@ def build_virtual_machine_scale_set_rolling_upgrades_cancel_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_edge_zone_get_request( # pylint: disable=name-too-long + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, + version: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1215,12 +1224,16 @@ def build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), + "version": _SERIALIZER.url("version", version, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1231,11 +1244,11 @@ def build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_list_by_edge_zone_request( # pylint: disable=name-too-long + location: str, edge_zone: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1246,12 +1259,12 @@ def build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_req # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/vmimages", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1262,11 +1275,11 @@ def build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_req # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_images_list_publishers_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1276,13 +1289,11 @@ def build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( # pyli # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1296,32 +1307,24 @@ def build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( # pyli return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_extensions_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long + location: str, publisher_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1330,39 +1333,30 @@ def build_virtual_machine_scale_set_vm_extensions_create_or_update_request( # p _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_extensions_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long + location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1371,19 +1365,21 @@ def build_virtual_machine_scale_set_vm_extensions_update_request( # pylint: dis _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, +def build_virtual_machine_images_list_request( # pylint: disable=name-too-long + location: str, + publisher_name: str, + offer: str, + skus: str, subscription_id: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1395,36 +1391,35 @@ def build_virtual_machine_scale_set_vm_extensions_delete_request( # pylint: dis # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_extensions_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_images_get_request( + location: str, publisher_name: str, offer: str, skus: str, version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1435,21 +1430,20 @@ def build_virtual_machine_scale_set_vm_extensions_get_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), + "version": _SERIALIZER.url("version", version, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1458,13 +1452,16 @@ def build_virtual_machine_scale_set_vm_extensions_get_request( # pylint: disabl return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_extensions_list_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, +def build_virtual_machine_images_list_with_properties_request( # pylint: disable=name-too-long + location: str, + publisher_name: str, + offer: str, + skus: str, subscription_id: str, *, - expand: Optional[str] = None, + expand: Union[str, _models.Expand], + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1476,21 +1473,25 @@ def build_virtual_machine_scale_set_vm_extensions_list_request( # pylint: disab # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), + "skus": _SERIALIZER.url("skus", skus, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1498,8 +1499,8 @@ def build_virtual_machine_scale_set_vm_extensions_list_request( # pylint: disab return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_reimage_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_log_analytics_export_request_rate_by_interval_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1511,13 +1512,11 @@ def build_virtual_machine_scale_set_vms_reimage_request( # pylint: disable=name # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1533,25 +1532,24 @@ def build_virtual_machine_scale_set_vms_reimage_request( # pylint: disable=name return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_log_analytics_export_throttled_requests_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1560,13 +1558,15 @@ def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable= _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_extension_images_list_types_request( # pylint: disable=name-too-long + location: str, publisher_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1577,13 +1577,12 @@ def build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( # pyli # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/approveRollingUpgrade", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1594,11 +1593,19 @@ def build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( # pyli # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_extension_images_list_versions_request( # pylint: disable=name-too-long + location: str, + publisher_name: str, + type: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1609,53 +1616,52 @@ def build_virtual_machine_scale_set_vms_deallocate_request( # pylint: disable=n # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "type": _SERIALIZER.url("type", type, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_extension_images_get_request( # pylint: disable=name-too-long + location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "type": _SERIALIZER.url("type", type, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1664,89 +1670,63 @@ def build_virtual_machine_scale_set_vms_update_request( # pylint: disable=name- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any +def build_virtual_machine_run_commands_list_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_deletion is not None: - _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any +def build_virtual_machine_run_commands_get_request( # pylint: disable=name-too-long + location: str, command_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "commandId": _SERIALIZER.url("command_id", command_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1755,8 +1735,8 @@ def build_virtual_machine_scale_set_vms_get_request( # pylint: disable=name-too return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_get_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_run_commands_list_by_virtual_machine_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1767,19 +1747,22 @@ def build_virtual_machine_scale_set_vms_get_instance_view_request( # pylint: di # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1787,13 +1770,12 @@ def build_virtual_machine_scale_set_vms_get_instance_view_request( # pylint: di return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_list_request( # pylint: disable=name-too-long +def build_virtual_machine_run_commands_get_by_virtual_machine_request( # pylint: disable=name-too-long resource_group_name: str, - virtual_machine_scale_set_name: str, + vm_name: str, + run_command_name: str, subscription_id: str, *, - filter: Optional[str] = None, - select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: @@ -1806,26 +1788,23 @@ def build_virtual_machine_scale_set_vms_list_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "virtualMachineScaleSetName": _SERIALIZER.url( - "virtual_machine_scale_set_name", virtual_machine_scale_set_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1833,65 +1812,65 @@ def build_virtual_machine_scale_set_vms_list_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_power_off_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any +def build_virtual_machine_run_commands_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if skip_shutdown is not None: - _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_restart_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_run_commands_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1900,13 +1879,15 @@ def build_virtual_machine_scale_set_vms_restart_request( # pylint: disable=name _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_start_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_run_commands_delete_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1917,13 +1898,15 @@ def build_virtual_machine_scale_set_vms_start_request( # pylint: disable=name-t # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1934,12 +1917,10 @@ def build_virtual_machine_scale_set_vms_start_request( # pylint: disable=name-t # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_usage_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1948,14 +1929,11 @@ def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=nam # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1966,17 +1944,11 @@ def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=nam # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - subscription_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_list_by_location_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1987,32 +1959,26 @@ def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_list_all_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2022,14 +1988,10 @@ def build_virtual_machine_scale_set_vms_perform_maintenance_request( # pylint: # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2040,11 +2002,11 @@ def build_virtual_machine_scale_set_vms_perform_maintenance_request( # pylint: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_simulate_eviction_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_list_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2055,13 +2017,13 @@ def build_virtual_machine_scale_set_vms_simulate_eviction_request( # pylint: di # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2072,64 +2034,76 @@ def build_virtual_machine_scale_set_vms_simulate_eviction_request( # pylint: di # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_get_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/attachDetachDataDisks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vms_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2138,15 +2112,25 @@ def build_virtual_machine_scale_set_vms_run_command_request( # pylint: disable= _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extensions_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_update_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2158,13 +2142,14 @@ def build_virtual_machine_extensions_create_or_update_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2173,67 +2158,78 @@ def build_virtual_machine_extensions_create_or_update_request( # pylint: disabl _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extensions_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force_deletion is not None: + _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extensions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/approveRollingUpgrade", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2242,173 +2238,200 @@ def build_virtual_machine_extensions_delete_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extensions_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_convert_to_single_placement_group_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extensions_list_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_virtual_machine_scale_sets_deallocate_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + hibernate: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if hibernate is not None: + _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_list_by_location_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_delete_instances_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force_deletion is not None: + _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_capture_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + platform_update_domain: int, + zone: Optional[str] = None, + placement_group_id: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["platformUpdateDomain"] = _SERIALIZER.query("platform_update_domain", platform_update_domain, "int") + if zone is not None: + _params["zone"] = _SERIALIZER.query("zone", zone, "str") + if placement_group_id is not None: + _params["placementGroupId"] = _SERIALIZER.query("placement_group_id", placement_group_id, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2417,25 +2440,13 @@ def build_virtual_machines_create_or_update_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_update_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_update_instances_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2447,12 +2458,14 @@ def build_virtual_machines_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2461,24 +2474,15 @@ def build_virtual_machines_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_delete_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - force_deletion: Optional[bool] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_get_os_upgrade_history_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2489,98 +2493,108 @@ def build_virtual_machines_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if force_deletion is not None: - _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_get_request( - resource_group_name: str, - vm_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_perform_maintenance_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_instance_view_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_power_off_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + subscription_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_shutdown is not None: + _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_reapply_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2591,12 +2605,14 @@ def build_virtual_machines_convert_to_managed_disks_request( # pylint: disable= # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reapply", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2610,57 +2626,63 @@ def build_virtual_machines_convert_to_managed_disks_request( # pylint: disable= return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, *, hibernate: Optional[bool] = None, **kwargs: Any +def build_virtual_machine_scale_sets_redeploy_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if hibernate is not None: - _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_generalize_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_reimage_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2669,105 +2691,106 @@ def build_virtual_machines_generalize_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_list_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_reimage_all_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_list_all_request( - subscription_id: str, - *, - status_only: Optional[str] = None, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, - **kwargs: Any +def build_virtual_machine_scale_sets_restart_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if status_only is not None: - _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_list_available_sizes_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_virtual_machine_scale_sets_set_orchestration_service_state_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2776,13 +2799,15 @@ def build_virtual_machines_list_available_sizes_request( # pylint: disable=name _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_power_off_request( - resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any +def build_virtual_machine_scale_sets_list_skus_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2793,45 +2818,48 @@ def build_virtual_machines_power_off_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if skip_shutdown is not None: - _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_reapply_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_sets_start_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2840,13 +2868,15 @@ def build_virtual_machines_reapply_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_restart_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_list_by_location_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2857,12 +2887,11 @@ def build_virtual_machines_restart_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2873,11 +2902,16 @@ def build_virtual_machines_restart_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_start_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_list_all_request( + subscription_id: str, + *, + status_only: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2886,29 +2920,35 @@ def build_virtual_machines_start_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if status_only is not None: + _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_redeploy_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_list_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2919,117 +2959,143 @@ def build_virtual_machines_redeploy_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_reimage_request( - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_get_request( + resource_group_name: str, + vm_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long +def build_virtual_machines_create_or_update_request( # pylint: disable=name-too-long resource_group_name: str, vm_name: str, subscription_id: str, *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if sas_uri_expiration_time_in_minutes is not None: - _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( - "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_update_request( + resource_group_name: str, + vm_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3038,13 +3104,24 @@ def build_virtual_machines_perform_maintenance_request( # pylint: disable=name- _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_simulate_eviction_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_delete_request( + resource_group_name: str, + vm_name: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3055,23 +3132,27 @@ def build_virtual_machines_simulate_eviction_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force_deletion is not None: + _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_virtual_machines_assess_patches_request( # pylint: disable=name-too-long @@ -3089,9 +3170,11 @@ def build_virtual_machines_assess_patches_request( # pylint: disable=name-too-l "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3105,7 +3188,7 @@ def build_virtual_machines_assess_patches_request( # pylint: disable=name-too-l return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_install_patches_request( # pylint: disable=name-too-long +def build_virtual_machines_attach_detach_data_disks_request( # pylint: disable=name-too-long resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3118,12 +3201,14 @@ def build_virtual_machines_install_patches_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/attachDetachDataDisks", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3139,7 +3224,7 @@ def build_virtual_machines_install_patches_request( # pylint: disable=name-too- return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_attach_detach_data_disks_request( # pylint: disable=name-too-long +def build_virtual_machines_capture_request( resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3152,12 +3237,14 @@ def build_virtual_machines_attach_detach_data_disks_request( # pylint: disable= # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/attachDetachDataDisks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3173,25 +3260,26 @@ def build_virtual_machines_attach_detach_data_disks_request( # pylint: disable= return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_migrate_to_vm_scale_set_request( # pylint: disable=name-too-long +def build_virtual_machines_convert_to_managed_disks_request( # pylint: disable=name-too-long resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/migrateToVirtualMachineScaleSet", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3200,49 +3288,48 @@ def build_virtual_machines_migrate_to_vm_scale_set_request( # pylint: disable=n _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if hibernate is not None: + _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_get_request( - location: str, publisher_name: str, offer: str, skus: str, version: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_generalize_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3253,15 +3340,14 @@ def build_virtual_machine_images_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "version": _SERIALIZER.url("version", version, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3272,59 +3358,47 @@ def build_virtual_machine_images_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - offer: str, - skus: str, - subscription_id: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any +def build_virtual_machines_install_patches_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_offers_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_instance_view_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3335,12 +3409,14 @@ def build_virtual_machine_images_list_offers_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3354,22 +3430,27 @@ def build_virtual_machine_images_list_offers_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_publishers_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_virtual_machines_migrate_to_vm_scale_set_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers" + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/migrateToVirtualMachineScaleSet", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3378,13 +3459,15 @@ def build_virtual_machine_images_list_publishers_request( # pylint: disable=nam _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too-long - location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_perform_maintenance_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3395,13 +3478,14 @@ def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3412,11 +3496,11 @@ def build_virtual_machine_images_list_skus_request( # pylint: disable=name-too- # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_by_edge_zone_request( # pylint: disable=name-too-long - location: str, edge_zone: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_power_off_request( + resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3427,36 +3511,31 @@ def build_virtual_machine_images_list_by_edge_zone_request( # pylint: disable=n # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/vmimages", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_shutdown is not None: + _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_list_with_properties_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - offer: str, - skus: str, - subscription_id: str, - *, - expand: Union[str, _models.Expand], - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any +def build_virtual_machines_reapply_request( + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3467,41 +3546,29 @@ def build_virtual_machine_images_list_with_properties_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_edge_zone_get_request( # pylint: disable=name-too-long - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, - version: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machines_redeploy_request( + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3512,16 +3579,14 @@ def build_virtual_machine_images_edge_zone_get_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "version": _SERIALIZER.url("version", version, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3532,61 +3597,47 @@ def build_virtual_machine_images_edge_zone_get_request( # pylint: disable=name- # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_edge_zone_list_request( # pylint: disable=name-too-long - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, - subscription_id: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any +def build_virtual_machines_reimage_request( + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "skus": _SERIALIZER.url("skus", skus, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_edge_zone_list_offers_request( # pylint: disable=name-too-long - location: str, edge_zone: str, publisher_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_restart_request( + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3597,13 +3648,14 @@ def build_virtual_machine_images_edge_zone_list_offers_request( # pylint: disab # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3614,11 +3666,16 @@ def build_virtual_machine_images_edge_zone_list_offers_request( # pylint: disab # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_edge_zone_list_publishers_request( # pylint: disable=name-too-long - location: str, edge_zone: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_name: str, + subscription_id: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3629,45 +3686,52 @@ def build_virtual_machine_images_edge_zone_list_publishers_request( # pylint: d # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if sas_uri_expiration_time_in_minutes is not None: + _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( + "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" + ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_images_edge_zone_list_skus_request( # pylint: disable=name-too-long - location: str, edge_zone: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_run_command_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "offer": _SERIALIZER.url("offer", offer, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3676,13 +3740,15 @@ def build_virtual_machine_images_edge_zone_list_skus_request( # pylint: disable _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extension_images_get_request( # pylint: disable=name-too-long - location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_simulate_eviction_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3693,14 +3759,14 @@ def build_virtual_machine_extension_images_get_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "type": _SERIALIZER.url("type", type, "str"), - "version": _SERIALIZER.url("version", version, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3711,11 +3777,11 @@ def build_virtual_machine_extension_images_get_request( # pylint: disable=name- # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extension_images_list_types_request( # pylint: disable=name-too-long - location: str, publisher_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machines_start_request( + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3726,12 +3792,14 @@ def build_virtual_machine_extension_images_list_types_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3742,19 +3810,11 @@ def build_virtual_machine_extension_images_list_types_request( # pylint: disabl # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_extension_images_list_versions_request( # pylint: disable=name-too-long - location: str, - publisher_name: str, - type: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any +def build_virtual_machines_list_available_sizes_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3765,24 +3825,19 @@ def build_virtual_machine_extension_images_list_versions_request( # pylint: dis # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str"), - "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), - "type": _SERIALIZER.url("type", type, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -3791,25 +3846,20 @@ def build_virtual_machine_extension_images_list_versions_request( # pylint: dis return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_virtual_machine_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3818,32 +3868,26 @@ def build_availability_sets_create_or_update_request( # pylint: disable=name-to _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_update_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_proximity_placement_groups_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3852,15 +3896,13 @@ def build_availability_sets_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_delete_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_proximity_placement_groups_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3871,12 +3913,13 @@ def build_availability_sets_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3887,12 +3930,17 @@ def build_availability_sets_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_get_request( - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_proximity_placement_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, + proximity_placement_group_name: str, + subscription_id: str, + *, + include_colocation_status: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -3902,18 +3950,26 @@ def build_availability_sets_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include_colocation_status is not None: + _params["includeColocationStatus"] = _SERIALIZER.query( + "include_colocation_status", include_colocation_status, "str" + ) # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -3921,49 +3977,29 @@ def build_availability_sets_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3972,29 +4008,36 @@ def build_availability_sets_list_request(resource_group_name: str, subscription_ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_list_available_sizes_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_proximity_placement_groups_update_request( # pylint: disable=name-too-long + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4003,30 +4046,35 @@ def build_availability_sets_list_available_sizes_request( # pylint: disable=nam _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_start_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_proximity_placement_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/startMigrationToVirtualMachineScaleSet", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4035,15 +4083,13 @@ def build_availability_sets_start_migration_to_virtual_machine_scale_set_request _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_list_all_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4053,13 +4099,10 @@ def build_availability_sets_cancel_migration_to_virtual_machine_scale_set_reques # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/cancelMigrationToVirtualMachineScaleSet", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections" + ) path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4070,28 +4113,28 @@ def build_availability_sets_cancel_migration_to_virtual_machine_scale_set_reques # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_list_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/validateMigrationToVirtualMachineScaleSet", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4100,49 +4143,55 @@ def build_availability_sets_validate_migration_to_virtual_machine_scale_set_requ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_availability_sets_convert_to_virtual_machine_scale_set_request( # pylint: disable=name-too-long - resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_get_request( # pylint: disable=name-too-long + resource_group_name: str, + restore_point_collection_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/convertToVirtualMachineScaleSet", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4154,14 +4203,16 @@ def build_proximity_placement_groups_create_or_update_request( # pylint: disabl # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4177,8 +4228,8 @@ def build_proximity_placement_groups_create_or_update_request( # pylint: disabl return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_update_request( # pylint: disable=name-too-long + resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4190,14 +4241,16 @@ def build_proximity_placement_groups_update_request( # pylint: disable=name-too # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4213,8 +4266,8 @@ def build_proximity_placement_groups_update_request( # pylint: disable=name-too return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any +def build_restore_point_collections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4225,14 +4278,16 @@ def build_proximity_placement_groups_delete_request( # pylint: disable=name-too # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4246,13 +4301,8 @@ def build_proximity_placement_groups_delete_request( # pylint: disable=name-too return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_get_request( # pylint: disable=name-too-long - resource_group_name: str, - proximity_placement_group_name: str, - subscription_id: str, - *, - include_colocation_status: Optional[str] = None, - **kwargs: Any +def build_ssh_public_keys_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4261,25 +4311,14 @@ def build_proximity_placement_groups_get_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "proximityPlacementGroupName": _SERIALIZER.url( - "proximity_placement_group_name", proximity_placement_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if include_colocation_status is not None: - _params["includeColocationStatus"] = _SERIALIZER.query( - "include_colocation_status", include_colocation_status, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -4288,8 +4327,8 @@ def build_proximity_placement_groups_get_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any +def build_ssh_public_keys_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4299,10 +4338,14 @@ def build_proximity_placement_groups_list_by_subscription_request( # pylint: di # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" - ) + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4316,8 +4359,8 @@ def build_proximity_placement_groups_list_by_subscription_request( # pylint: di return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_proximity_placement_groups_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_ssh_public_keys_get_request( + resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4328,11 +4371,14 @@ def build_proximity_placement_groups_list_by_resource_group_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4346,8 +4392,8 @@ def build_proximity_placement_groups_list_by_resource_group_request( # pylint: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +def build_ssh_public_keys_create_request( + resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4359,12 +4405,14 @@ def build_dedicated_host_groups_create_or_update_request( # pylint: disable=nam # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4380,8 +4428,8 @@ def build_dedicated_host_groups_create_or_update_request( # pylint: disable=nam return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +def build_ssh_public_keys_update_request( + resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4393,12 +4441,14 @@ def build_dedicated_host_groups_update_request( # pylint: disable=name-too-long # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4414,8 +4464,8 @@ def build_dedicated_host_groups_update_request( # pylint: disable=name-too-long return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +def build_ssh_public_keys_delete_request( + resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4426,12 +4476,14 @@ def build_dedicated_host_groups_delete_request( # pylint: disable=name-too-long # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4445,46 +4497,44 @@ def build_dedicated_host_groups_delete_request( # pylint: disable=name-too-long return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_get_request( - resource_group_name: str, - host_group_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any +def build_ssh_public_keys_generate_key_pair_request( # pylint: disable=name-too-long + resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservations_list_by_capacity_reservation_group_request( # pylint: disable=name-too-long + resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4495,11 +4545,16 @@ def build_dedicated_host_groups_list_by_resource_group_request( # pylint: disab # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4513,8 +4568,14 @@ def build_dedicated_host_groups_list_by_resource_group_request( # pylint: disab return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_host_groups_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any +def build_capacity_reservations_get_request( + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4523,15 +4584,27 @@ def build_dedicated_host_groups_list_by_subscription_request( # pylint: disable accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), + "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -4539,8 +4612,12 @@ def build_dedicated_host_groups_list_by_subscription_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservations_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4552,13 +4629,17 @@ def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), + "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4574,8 +4655,12 @@ def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too- return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_update_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservations_update_request( # pylint: disable=name-too-long + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4587,13 +4672,17 @@ def build_dedicated_hosts_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), + "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4609,8 +4698,12 @@ def build_dedicated_hosts_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +def build_capacity_reservations_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4621,13 +4714,17 @@ def build_dedicated_hosts_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "hostName": _SERIALIZER.url("host_name", host_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_name, "str" + ), + "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4641,6 +4738,39 @@ def build_dedicated_hosts_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) +def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long + resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_dedicated_hosts_get_request( resource_group_name: str, host_group_name: str, @@ -4662,18 +4792,20 @@ def build_dedicated_hosts_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), "hostName": _SERIALIZER.url("host_name", host_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -4681,24 +4813,28 @@ def build_dedicated_hosts_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-too-long - resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4707,30 +4843,35 @@ def build_dedicated_hosts_list_by_host_group_request( # pylint: disable=name-to _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_restart_request( +def build_dedicated_hosts_update_request( resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), "hostName": _SERIALIZER.url("host_name", host_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4739,12 +4880,14 @@ def build_dedicated_hosts_restart_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_dedicated_hosts_redeploy_request( +def build_dedicated_hosts_delete_request( resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4756,13 +4899,15 @@ def build_dedicated_hosts_redeploy_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/redeploy", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str", pattern=r"^[-\w\._]+$"), - "hostName": _SERIALIZER.url("host_name", host_name, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4773,7 +4918,7 @@ def build_dedicated_hosts_redeploy_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_dedicated_hosts_list_available_sizes_request( # pylint: disable=name-too-long @@ -4791,10 +4936,12 @@ def build_dedicated_hosts_list_available_sizes_request( # pylint: disable=name- "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/hostSizes", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str", pattern=r"^[-\w\._]+$"), - "hostName": _SERIALIZER.url("host_name", host_name, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4808,8 +4955,8 @@ def build_dedicated_hosts_list_available_sizes_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any +def build_dedicated_hosts_redeploy_request( + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4818,9 +4965,17 @@ def build_ssh_public_keys_list_by_subscription_request( # pylint: disable=name- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/redeploy", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4831,11 +4986,11 @@ def build_ssh_public_keys_list_by_subscription_request( # pylint: disable=name- # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_dedicated_hosts_restart_request( + resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4846,11 +5001,15 @@ def build_ssh_public_keys_list_by_resource_group_request( # pylint: disable=nam # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"), + "hostName": _SERIALIZER.url("host_name", host_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4861,45 +5020,59 @@ def build_ssh_public_keys_list_by_resource_group_request( # pylint: disable=nam # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_create_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any +def build_restore_points_get_request( + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_update_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any +def build_restore_points_create_request( + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4911,12 +5084,17 @@ def build_ssh_public_keys_update_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4929,11 +5107,15 @@ def build_ssh_public_keys_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_delete_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any +def build_restore_points_delete_request( + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4944,12 +5126,17 @@ def build_ssh_public_keys_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "restorePointCollectionName": _SERIALIZER.url( + "restore_point_collection_name", restore_point_collection_name, "str" + ), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4963,8 +5150,8 @@ def build_ssh_public_keys_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_get_request( - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -4975,12 +5162,14 @@ def build_ssh_public_keys_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4991,28 +5180,29 @@ def build_ssh_public_keys_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_ssh_public_keys_generate_key_pair_request( # pylint: disable=name-too-long - resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5021,32 +5211,31 @@ def build_ssh_public_keys_generate_key_pair_request( # pylint: disable=name-too _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_create_or_update_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_rolling_upgrades_cancel_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "imageName": _SERIALIZER.url("image_name", image_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5055,32 +5244,31 @@ def build_images_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_update_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "imageName": _SERIALIZER.url("image_name", image_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5089,15 +5277,13 @@ def build_images_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_delete_request( - resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_extensions_list_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5108,12 +5294,14 @@ def build_images_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "imageName": _SERIALIZER.url("image_name", image_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5124,11 +5312,17 @@ def build_images_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_get_request( - resource_group_name: str, image_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_virtual_machine_scale_set_extensions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5139,20 +5333,23 @@ def build_images_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "imageName": _SERIALIZER.url("image_name", image_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -5160,23 +5357,28 @@ def build_images_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_extensions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5185,22 +5387,35 @@ def build_images_list_by_resource_group_request( # pylint: disable=name-too-lon _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_images_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_virtual_machine_scale_set_extensions_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5209,32 +5424,34 @@ def build_images_list_request(subscription_id: str, **kwargs: Any) -> HttpReques _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_extensions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5243,33 +5460,39 @@ def build_restore_point_collections_create_or_update_request( # pylint: disable _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_update_request( # pylint: disable=name-too-long - resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_list_request( # pylint: disable=name-too-long + resource_group_name: str, + virtual_machine_scale_set_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + select: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "virtualMachineScaleSetName": _SERIALIZER.url( + "virtual_machine_scale_set_name", virtual_machine_scale_set_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" ), } @@ -5277,17 +5500,27 @@ def build_restore_point_collections_update_request( # pylint: disable=name-too- # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_delete_request( # pylint: disable=name-too-long - resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_get_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5298,69 +5531,86 @@ def build_restore_point_collections_delete_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_get_request( # pylint: disable=name-too-long +def build_virtual_machine_scale_set_vms_update_request( # pylint: disable=name-too-long resource_group_name: str, - restore_point_collection_name: str, + vm_scale_set_name: str, + instance_id: str, subscription_id: str, *, - expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_list_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5371,26 +5621,32 @@ def build_restore_point_collections_list_request( # pylint: disable=name-too-lo # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force_deletion is not None: + _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_point_collections_list_all_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5400,10 +5656,16 @@ def build_restore_point_collections_list_all_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections" - ) + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/approveRollingUpgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5414,15 +5676,11 @@ def build_restore_point_collections_list_all_request( # pylint: disable=name-to # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_points_create_request( - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5434,15 +5692,15 @@ def build_restore_points_create_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/attachDetachDataDisks", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5455,15 +5713,11 @@ def build_restore_points_create_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_points_delete_request( - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_scale_set_vms_deallocate_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5474,15 +5728,15 @@ def build_restore_points_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5493,17 +5747,11 @@ def build_restore_points_delete_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_points_get_request( - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, - **kwargs: Any +def build_virtual_machine_scale_set_vms_get_instance_view_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5514,22 +5762,20 @@ def build_restore_points_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "restorePointCollectionName": _SERIALIZER.url( - "restore_point_collection_name", restore_point_collection_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -5538,27 +5784,27 @@ def build_restore_points_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_perform_maintenance_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/performMaintenance", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5567,51 +5813,55 @@ def build_capacity_reservation_groups_create_or_update_request( # pylint: disab _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_update_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_power_off_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/powerOff", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip_shutdown is not None: + _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_delete_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5622,14 +5872,15 @@ def build_capacity_reservation_groups_delete_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/redeploy", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5640,55 +5891,48 @@ def build_capacity_reservation_groups_delete_request( # pylint: disable=name-to # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_get_request( # pylint: disable=name-too-long - resource_group_name: str, - capacity_reservation_group_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, - **kwargs: Any +def build_virtual_machine_scale_set_vms_reimage_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - **kwargs: Any +def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5699,32 +5943,30 @@ def build_capacity_reservation_groups_list_by_resource_group_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservation_groups_list_by_subscription_request( # pylint: disable=name-too-long - subscription_id: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, - **kwargs: Any +def build_virtual_machine_scale_set_vms_restart_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5734,74 +5976,75 @@ def build_capacity_reservation_groups_list_by_subscription_request( # pylint: d # Construct URL _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups" + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/restart", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if resource_ids_only is not None: - _params["resourceIdsOnly"] = _SERIALIZER.query("resource_ids_only", resource_ids_only, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservations_create_or_update_request( # pylint: disable=name-too-long +def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: str, subscription_id: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/retrieveBootDiagnosticsData", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if sas_uri_expiration_time_in_minutes is not None: + _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query( + "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int" + ) # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservations_update_request( # pylint: disable=name-too-long - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_scale_set_vms_run_command_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5813,15 +6056,15 @@ def build_capacity_reservations_update_request( # pylint: disable=name-too-long # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommand", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5834,15 +6077,11 @@ def build_capacity_reservations_update_request( # pylint: disable=name-too-long _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservations_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - subscription_id: str, - **kwargs: Any +def build_virtual_machine_scale_set_vms_simulate_eviction_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5853,15 +6092,15 @@ def build_capacity_reservations_delete_request( # pylint: disable=name-too-long # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -5872,17 +6111,11 @@ def build_capacity_reservations_delete_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservations_get_request( - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - subscription_id: str, - *, - expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, - **kwargs: Any +def build_virtual_machine_scale_set_vms_start_request( # pylint: disable=name-too-long + resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5893,32 +6126,36 @@ def build_capacity_reservations_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/start", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_capacity_reservations_list_by_capacity_reservation_group_request( # pylint: disable=name-too-long - resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vm_extensions_list_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5929,20 +6166,23 @@ def build_capacity_reservations_list_by_capacity_reservation_group_request( # p # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "capacityReservationGroupName": _SERIALIZER.url( - "capacity_reservation_group_name", capacity_reservation_group_name, "str" + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -5950,41 +6190,57 @@ def build_capacity_reservations_list_by_capacity_reservation_group_request( # p return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_log_analytics_export_request_rate_by_interval_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vm_extensions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_log_analytics_export_throttled_requests_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vm_extensions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -5996,11 +6252,16 @@ def build_log_analytics_export_throttled_requests_request( # pylint: disable=na # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6013,124 +6274,37 @@ def build_log_analytics_export_throttled_requests_request( # pylint: disable=na _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_run_commands_list_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands" - ) # pylint: disable=line-too-long - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_get_request( # pylint: disable=name-too-long - location: str, command_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_virtual_machine_run_commands_update_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vm_extensions_update_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6146,25 +6320,33 @@ def build_virtual_machine_run_commands_update_request( # pylint: disable=name-t return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_run_commands_delete_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any +def build_virtual_machine_scale_set_vm_extensions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6178,10 +6360,10 @@ def build_virtual_machine_run_commands_delete_request( # pylint: disable=name-t return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_run_commands_get_by_virtual_machine_request( # pylint: disable=name-too-long +def build_virtual_machine_scale_set_vm_run_commands_list_request( # pylint: disable=name-too-long resource_group_name: str, - vm_name: str, - run_command_name: str, + vm_scale_set_name: str, + instance_id: str, subscription_id: str, *, expand: Optional[str] = None, @@ -6191,26 +6373,28 @@ def build_virtual_machine_run_commands_get_by_virtual_machine_request( # pylint _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -6218,32 +6402,43 @@ def build_virtual_machine_run_commands_get_by_virtual_machine_request( # pylint return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_run_commands_list_by_virtual_machine_request( # pylint: disable=name-too-long - resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +def build_virtual_machine_scale_set_vm_run_commands_get_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), + "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), + "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -6264,7 +6459,7 @@ def build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( # api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( @@ -6272,11 +6467,13 @@ def build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( # "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6305,7 +6502,7 @@ def build_virtual_machine_scale_set_vm_run_commands_update_request( # pylint: d api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( @@ -6313,11 +6510,13 @@ def build_virtual_machine_scale_set_vm_run_commands_update_request( # pylint: d "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6345,7 +6544,7 @@ def build_virtual_machine_scale_set_vm_run_commands_delete_request( # pylint: d _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( @@ -6353,11 +6552,13 @@ def build_virtual_machine_scale_set_vm_run_commands_delete_request( # pylint: d "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -6371,41 +6572,34 @@ def build_virtual_machine_scale_set_vm_run_commands_delete_request( # pylint: d return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_run_commands_get_request( # pylint: disable=name-too-long - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any +def build_virtual_machine_extensions_list_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -6413,10 +6607,10 @@ def build_virtual_machine_scale_set_vm_run_commands_get_request( # pylint: disa return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machine_scale_set_vm_run_commands_list_request( # pylint: disable=name-too-long +def build_virtual_machine_extensions_get_request( # pylint: disable=name-too-long resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, + vm_name: str, + vm_extension_name: str, subscription_id: str, *, expand: Optional[str] = None, @@ -6426,26 +6620,28 @@ def build_virtual_machine_scale_set_vm_run_commands_list_request( # pylint: dis _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"), - "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -6453,110 +6649,122 @@ def build_virtual_machine_scale_set_vm_run_commands_list_request( # pylint: dis return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models +def build_virtual_machine_extensions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ComputeOperationValue"]: - """Gets a list of compute operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), + } - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _url: str = _url.format(**path_format_arguments) # type: ignore - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ComputeOperationListResult] = kwargs.pop("cls", None) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - def prepare_request(next_link=None): - if not next_link: + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - _request = build_operations_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request +def build_virtual_machine_extensions_update_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("ComputeOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - def get_next(next_link=None): - _request = prepare_request(next_link) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), + } - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _url: str = _url.format(**path_format_arguments) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return pipeline_response + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return ItemPaged(get_next, extract_data) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class UsageOperations: +def build_virtual_machine_extensions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmName": _SERIALIZER.url("vm_name", vm_name, "str"), + "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`usage` attribute. + :attr:`operations` attribute. """ models = _models @@ -6570,21 +6778,18 @@ def __init__(self, *args, **kwargs): self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: - """Gets, for the specified location, the current compute resource usage information as well as the - limits for compute resources under the subscription. + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. - :param location: The location for which resource usage is queried. Required. - :type location: str - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Usage] + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6597,9 +6802,7 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: def prepare_request(next_link=None): if not next_link: - _request = build_usage_list_request( - location=location, - subscription_id=self._config.subscription_id, + _request = build_operations_list_request( api_version=api_version, headers=_headers, params=_params, @@ -6624,7 +6827,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("ListUsagesResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6641,21 +6844,22 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) -class VirtualMachineSizesOperations: +class AvailabilitySetsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. + :attr:`availability_sets` attribute. """ models = _models @@ -6669,21 +6873,23 @@ def __init__(self, *args, **kwargs): self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineSize"]: - """This API is deprecated. Use `Resources Skus - `_. + def list_by_subscription( + self, *, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.AvailabilitySet"]: + """Lists all availability sets in a subscription. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :keyword expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6696,9 +6902,9 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachine def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_sizes_list_request( - location=location, + _request = build_availability_sets_list_by_subscription_request( subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -6723,11 +6929,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -6746,45 +6952,22 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: - """Gets all the VM scale sets under the specified subscription for the specified location. + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AvailabilitySet"]: + """Lists all availability sets in a resource group. - :param location: The location for which VM scale sets under the subscription are queried. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type location: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :type resource_group_name: str + :return: An iterator like instance of either AvailabilitySet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6797,8 +6980,8 @@ def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Vi def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_by_location_request( - location=location, + _request = build_availability_sets_list_request( + resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -6824,7 +7007,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -6847,16 +7030,19 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: + """Retrieves information about an availability set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6865,53 +7051,34 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSet") + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_create_or_update_request( + _request = build_availability_sets_get_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6919,174 +7086,81 @@ def _create_or_update_initial( return deserialized # type: ignore @overload - def begin_create_or_update( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSet, + availability_set_name: str, + parameters: _models.AvailabilitySet, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, + availability_set_name: str, parameters: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Required. :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + availability_set_name: str, + parameters: Union[_models.AvailabilitySet, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Create or update a VM scale set. + ) -> _models.AvailabilitySet: + """Create or update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Create Availability Set operation. Is either a + AvailabilitySet type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7100,7 +7174,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -7108,14 +7182,12 @@ def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") + _json = self._serialize.body(parameters, "AvailabilitySet") - _request = build_virtual_machine_scale_sets_update_request( + _request = build_availability_sets_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -7125,8 +7197,7 @@ def _update_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -7134,14 +7205,10 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7149,168 +7216,81 @@ def _update_initial( return deserialized # type: ignore @overload - def begin_update( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VirtualMachineScaleSetUpdate, + availability_set_name: str, + parameters: _models.AvailabilitySetUpdate, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def update( self, resource_group_name: str, - vm_scale_set_name: str, + availability_set_name: str, parameters: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Required. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Required. :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + availability_set_name: str, + parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSet]: - """Update a VM scale set. + ) -> _models.AvailabilitySet: + """Update an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set to create or update. Required. - :type vm_scale_set_name: str - :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate or - IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the Update Availability Set operation. Is either a + AvailabilitySetUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7319,40 +7299,46 @@ def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + + _request = build_availability_sets_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7360,84 +7346,71 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace - def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a VM scale set. + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> None: + """Delete an availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword force_deletion: Optional parameter to force delete a VM scale set. (Feature in - Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_availability_sets_delete_request( + resource_group_name=resource_group_name, + availability_set_name=availability_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a virtual machine scale set. + def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> None: + """Cancel the migration operation on an Availability Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the - UserData property of the VM scale set that was provided by the user during the VM scale set - Create/Update operation. "userData" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7452,13 +7425,12 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_get_request( + _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -7472,24 +7444,18 @@ def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - def _deallocate_initial( + def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -7510,19 +7476,18 @@ def _deallocate_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + if parameters is not None: + _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") else: _json = None - _request = build_virtual_machine_scale_sets_deallocate_request( + _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - hibernate=hibernate, api_version=api_version, content_type=content_type, json=_json, @@ -7540,7 +7505,7 @@ def _deallocate_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -7548,40 +7513,38 @@ def _deallocate_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_deallocate( + def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + availability_set_name: str, + parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, *, - hibernate: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -7591,31 +7554,26 @@ def begin_deallocate( """ @overload - def begin_deallocate( + def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + availability_set_name: str, + parameters: Optional[IO[bytes]] = None, *, - hibernate: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Default value is None. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -7625,31 +7583,25 @@ def begin_deallocate( """ @distributed_trace - def begin_deallocate( + def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - hibernate: Optional[bool] = None, + availability_set_name: str, + parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: - """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and - releases the compute resources. You are not billed for the compute resources that this virtual - machine scale set deallocates. + """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the + Availability Set. This does not trigger a downtime on the Virtual Machines. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. - (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is - None. - :paramtype hibernate: bool + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput + or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -7664,11 +7616,10 @@ def begin_deallocate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deallocate_initial( + raw_result = self._convert_to_virtual_machine_scale_set_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - hibernate=hibernate, + availability_set_name=availability_set_name, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -7684,7 +7635,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -7698,15 +7651,91 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_instances_initial( + @overload + def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, *, - force_deletion: Optional[bool] = None, + content_type: str = "application/json", **kwargs: Any - ) -> Iterator[bytes]: + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + self, + resource_group_name: str, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual + Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that + triggers a downtime on the Virtual Machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7720,21 +7749,20 @@ def _delete_instances_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - _request = build_virtual_machine_scale_sets_delete_instances_request( + _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, - force_deletion=force_deletion, api_version=api_version, content_type=content_type, json=_json, @@ -7744,175 +7772,100 @@ def _delete_instances_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - def begin_delete_instances( + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + availability_set_name: str, + parameters: _models.MigrateToVirtualMachineScaleSetInput, *, - force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_delete_instances( + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], + availability_set_name: str, + parameters: IO[bytes], *, - force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Required. - :type vm_instance_i_ds: IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_delete_instances( + def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, + availability_set_name: str, + parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - force_deletion=force_deletion, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.VirtualMachineScaleSetInstanceView: - """Gets the status of a VM scale set instance. + ) -> None: + """Validates that the Virtual Machines in the Availability Set can be migrated to the provided + Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: VirtualMachineScaleSetInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceView + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :param parameters: Parameters supplied to the migrate operation on the availability set. Is + either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + or IO[bytes] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7923,17 +7876,29 @@ def get_instance_view( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_get_instance_view_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + + _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7946,34 +7911,34 @@ def get_instance_view( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM scale sets under a resource group. + def list_available_sizes( + self, resource_group_name: str, availability_set_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachineSize"]: + """Lists all available virtual machine sizes that can be used to create a new virtual machine in + an existing availability set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :param availability_set_name: The name of the availability set. Required. + :type availability_set_name: str + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7986,8 +7951,9 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Vir def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_request( + _request = build_availability_sets_list_available_sizes_request( resource_group_name=resource_group_name, + availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -8013,7 +7979,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8036,23 +8002,64 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: - """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource - group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this - till nextLink is null to fetch all the VM Scale Sets. + def list_by_subscription( + self, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + **kwargs: Any + ) -> Iterable["_models.CapacityReservationGroup"]: + """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in + the response to get the next page of capacity reservation groups. - :return: An iterator like instance of either VirtualMachineScaleSet or the result of + :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) + specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are + associated to capacity reservation group in the response. Known values are: + "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups + :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. + :code:`
` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation + group resources created in the subscription. :code:`
` 'SharedWithSubscription' enables + fetching Resource Ids for all capacity reservation group resources shared with the + subscription. :code:`
` 'All' enables fetching Resource Ids for all capacity reservation + group resources shared with the subscription and created in the subscription. Known values are: + "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. + :paramtype resource_ids_only: str or + ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8065,8 +8072,10 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_all_request( + _request = build_capacity_reservation_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, + expand=expand, + resource_ids_only=resource_ids_only, api_version=api_version, headers=_headers, params=_params, @@ -8091,7 +8100,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListWithLinkResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8115,27 +8124,36 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_skus( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetSku"]: - """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM - instances allowed for each SKU. + def list_by_resource_group( + self, + resource_group_name: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + **kwargs: Any + ) -> Iterable["_models.CapacityReservationGroup"]: + """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink + property in the response to get the next page of capacity reservation groups. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of + :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) + specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are + associated to capacity reservation group in the response. Known values are: + "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups + :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8148,10 +8166,10 @@ def list_skus( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_list_skus_request( + _request = build_capacity_reservation_groups_list_by_resource_group_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -8176,7 +8194,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8200,27 +8218,32 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_os_upgrade_history( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.UpgradeOperationHistoricalStatusInfo"]: - """Gets list of OS upgrades on a VM scale set instance. + def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + *, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation that retrieves information about a capacity reservation group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the capacity reservations under the capacity reservation group + which is a snapshot of the runtime properties of a capacity reservation that is managed by the + platform and can change outside of control plane operations. "instanceView" Default value is + None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8229,69 +8252,123 @@ def get_os_upgrade_history( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_capacity_reservation_groups_get_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore - def _power_off_initial( + @overload + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + capacity_reservation_group_name: str, + parameters: _models.CapacityReservationGroup, *, - skip_shutdown: bool = False, + content_type: str = "application/json", **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroup, IO[bytes]], + **kwargs: Any + ) -> _models.CapacityReservationGroup: + """The operation to create or update a capacity reservation group. When updating a capacity + reservation group, only tags and sharing profile may be modified. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a + CapacityReservationGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8305,24 +8382,20 @@ def _power_off_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "CapacityReservationGroup") - _request = build_virtual_machine_scale_sets_power_off_request( + _request = build_capacity_reservation_groups_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, json=_json, @@ -8332,23 +8405,18 @@ def _power_off_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8356,158 +8424,87 @@ def _power_off_initial( return deserialized # type: ignore @overload - def begin_power_off( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + capacity_reservation_group_name: str, + parameters: _models.CapacityReservationGroupUpdate, *, - skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_power_off( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + capacity_reservation_group_name: str, + parameters: IO[bytes], *, - skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. + Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_power_off( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - *, - skip_shutdown: bool = False, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still - attached and you are getting charged for the resources. Instead, use deallocate to release - resources and avoid charges. Additionally, this operation is not allowed on virtual machines in - a VM scale set that are being deallocated or have already been deallocated. + ) -> _models.CapacityReservationGroup: + """The operation to update a capacity reservation group. When updating a capacity reservation + group, only tags and sharing profile may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param parameters: Parameters supplied to the Update capacity reservation Group operation. Is + either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate or + IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._power_off_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - skip_shutdown=skip_shutdown, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _restart_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8521,22 +8518,19 @@ def _restart_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") - _request = build_virtual_machine_scale_sets_restart_request( + _request = build_capacity_reservation_groups_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -8547,156 +8541,42 @@ def _restart_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_restart( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Restarts one or more virtual machines in a VM scale set. + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> None: + """The operation to delete a capacity reservation group. This operation is allowed only if all the + associated resources are disassociated from the reservation group and all capacity reservations + under the reservation group have also been deleted. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _start_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8705,181 +8585,72 @@ def _start_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_start_request( + _request = build_capacity_reservation_groups_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @overload - def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Starts one or more virtual machines in a VM scale set. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. + """ - @overload - def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Starts one or more virtual machines in a VM scale set. + models = _models - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_start( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Starts one or more virtual machines in a VM scale set. + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: + """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the + response to get the next page of dedicated host groups. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8888,111 +8659,162 @@ def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **k } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_virtual_machine_scale_sets_reapply_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + _request = build_dedicated_host_groups_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_reapply(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> LROPoller[None]: - """Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine - Instances. + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: + """Lists all of the dedicated host groups in the specified resource group. Use the nextLink + property in the response to get the next page of dedicated host groups. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reapply_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dedicated_host_groups_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, None, {}) # type: ignore + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - def _redeploy_initial( + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.DedicatedHostGroup: + """Retrieves information about a dedicated host group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is + not supported for dedicated host group. Known values are: "instanceView", "userData", and + "resiliencyView". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9001,54 +8823,35 @@ def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_redeploy_request( + _request = build_dedicated_host_groups_get_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9056,164 +8859,113 @@ def _redeploy_initial( return deserialized # type: ignore @overload - def begin_redeploy( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + host_group_name: str, + parameters: _models.DedicatedHostGroup, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_redeploy( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + host_group_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_redeploy( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, - and powers them back on. + ) -> _models.DedicatedHostGroup: + """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host + Groups please see [Dedicated Host Documentation] + (https://go.microsoft.com/fwlink/?linkid=2082596). - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a + DedicatedHostGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedHostGroup") - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _perform_maintenance_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds - else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None - - _request = build_virtual_machine_scale_sets_perform_maintenance_request( + _request = build_dedicated_host_groups_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -9224,23 +8976,18 @@ def _perform_maintenance_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9248,141 +8995,81 @@ def _perform_maintenance_initial( return deserialized # type: ignore @overload - def begin_perform_maintenance( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + host_group_name: str, + parameters: _models.DedicatedHostGroupUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_perform_maintenance( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + host_group_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_perform_maintenance( + def update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances - which are not eligible for perform maintenance will be failed. Please refer to best practices - for more details: - https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. + ) -> _models.DedicatedHostGroup: + """Update an dedicated host group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either + a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_instances_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9396,19 +9083,19 @@ def _update_instances_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") - _request = build_virtual_machine_scale_sets_update_instances_request( + _request = build_dedicated_host_groups_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -9419,156 +9106,39 @@ def _update_instances_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_group_name: str, **kwargs: Any + ) -> None: + """Delete a dedicated host group. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - - @overload - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. - Required. - :type vm_instance_i_ds: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_instances( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_instances_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9577,190 +9147,273 @@ def _reimage_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_reimage_input - else: - if vm_scale_set_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") - else: - _json = None + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_reimage_request( + _request = build_dedicated_host_groups_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`images` attribute. + """ - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. + models = _models - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. - :type vm_scale_set_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which - don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual - machine is reset to initial state. + def list(self, **kwargs: Any) -> Iterable["_models.Image"]: + """Gets the list of Images in the subscription. Use nextLink property in the response to get the + next page of Images. Do this till nextLink is null to fetch all the Images. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a - VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. - :type vm_scale_set_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def prepare_request(next_link=None): + if not next_link: + + _request = build_images_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - def _reimage_all_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Image"]: + """Gets the list of images under a resource group. Use nextLink property in the response to get + the next page of Images. Do this till nextLink is null to fetch all the Images. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_images_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ImageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Image: + """Gets an image. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: Image or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.Image + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) + + _request = build_images_get_request( + resource_group_name=resource_group_name, + image_name=image_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Image", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9780,17 +9433,14 @@ def _reimage_all_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "Image") - _request = build_virtual_machine_scale_sets_reimage_all_request( + _request = build_images_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -9809,7 +9459,7 @@ def _reimage_all_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -9817,91 +9467,88 @@ def _reimage_all_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_reimage_all( + def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + image_name: str, + parameters: _models.Image, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. + ) -> LROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_reimage_all( + def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + image_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. + ) -> LROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_reimage_all( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This - operation is only supported for managed disks. + def begin_create_or_update( + self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Image]: + """Create or update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9909,15 +9556,15 @@ def begin_reimage_all( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reimage_all_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, + image_name=image_name, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -9928,30 +9575,36 @@ def begin_reimage_all( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.Image].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _approve_rolling_upgrade_initial( + def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -9972,17 +9625,14 @@ def _approve_rolling_upgrade_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(vm_instance_i_ds, (IOBase, bytes)): - _content = vm_instance_i_ds + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - if vm_instance_i_ds is not None: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") - else: - _json = None + _json = self._serialize.body(parameters, "ImageUpdate") - _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( + _request = build_images_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -10001,7 +9651,7 @@ def _approve_rolling_upgrade_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -10010,7 +9660,9 @@ def _approve_rolling_upgrade_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -10020,83 +9672,79 @@ def _approve_rolling_upgrade_initial( return deserialized # type: ignore @overload - def begin_approve_rolling_upgrade( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + image_name: str, + parameters: _models.ImageUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + ) -> LROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_approve_rolling_upgrade( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[IO[bytes]] = None, + image_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + ) -> LROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default - value is None. - :type vm_instance_i_ds: IO[bytes] + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Required. + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_approve_rolling_upgrade( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale - set. + ) -> LROPoller[_models.Image]: + """Update an image. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is - either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param image_name: The name of the image. Required. + :type image_name: str + :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] + :return: An instance of LROPoller that returns either Image or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -10104,15 +9752,15 @@ def begin_approve_rolling_upgrade( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Image] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._approve_rolling_upgrade_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vm_instance_i_ds=vm_instance_i_ds, + image_name=image_name, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -10123,56 +9771,32 @@ def begin_approve_rolling_upgrade( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.Image].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long - self, - resource_group_name: str, - vm_scale_set_name: str, - *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoveryWalkResponse: - """Manual platform update domain walk to update virtual machines in a service fabric virtual - machine scale set. + return LROPoller[_models.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :keyword platform_update_domain: The platform update domain for which a manual recovery walk is - requested. Required. - :paramtype platform_update_domain: int - :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual - machine scale set. Default value is None. - :paramtype zone: str - :keyword placement_group_id: The placement group id for which the manual recovery walk is - requested. Default value is None. - :paramtype placement_group_id: str - :return: RecoveryWalkResponse or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10185,116 +9809,134 @@ def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disabl _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( + _request = build_images_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + image_name=image_name, subscription_id=self._config.subscription_id, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + @distributed_trace + def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes an Image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :type resource_group_name: str + :param image_name: The name of the image. Required. + :type image_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def convert_to_single_placement_group( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + image_name=image_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def convert_to_single_placement_group( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + def list_publishers( + self, location: str, edge_zone: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a - VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10305,29 +9947,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_edge_zone_list_publishers_request( + location=location, + edge_zone=edge_zone, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -10344,16 +9974,30 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - def _set_orchestration_service_state_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + return deserialized # type: ignore + + @distributed_trace + def list_offers( + self, location: str, edge_zone: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location, edge zone and + publisher. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10362,206 +10006,143 @@ def _set_orchestration_service_state_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_set_orchestration_service_state_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_edge_zone_list_offers_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: _models.OrchestrationServiceStateInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. + @distributed_trace + def list_skus( + self, location: str, edge_zone: str, publisher_name: str, offer: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and + offer. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Changes ServiceState property for a given service. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the virtual machine scale set to create or update. - Required. - :type vm_scale_set_name: str - :param parameters: The input object for SetOrchestrationServiceState API. Is either a - OrchestrationServiceStateInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput or - IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._set_orchestration_service_state_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_virtual_machine_images_edge_zone_list_skus_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response -class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. - """ + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - models = _models + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return deserialized # type: ignore - def _create_or_update_initial( + @distributed_trace + def list( self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any - ) -> Iterator[bytes]: + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, edge zone, + publisher, offer, and SKU. + + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :keyword top: An integer value specifying the number of images to return that matches supplied + values. Default value is None. + :paramtype top: int + :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. + Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10570,209 +10151,199 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_edge_zone_list_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. + @distributed_trace + def get( + self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineImage: + """Gets a virtual machine image in an edge zone. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param version: A valid image SKU version. Required. + :type version: str + :return: VirtualMachineImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_virtual_machine_images_edge_zone_get_request( + location=location, + edge_zone=edge_zone, + publisher_name=publisher_name, + offer=offer, + skus=skus, + version=version, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to create or update an extension. + def list_by_edge_zone(self, location: str, edge_zone: str, **kwargs: Any) -> _models.VmImagesInEdgeZoneListResult: + """Gets a list of all virtual machine image versions for the specified edge zone. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Create VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param edge_zone: The name of the edge zone. Required. + :type edge_zone: str + :return: VmImagesInEdgeZoneListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VmImagesInEdgeZoneListResult :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_virtual_machine_images_list_by_edge_zone_request( + location=location, + edge_zone=edge_zone, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image publishers for the specified Azure location. + + :param location: The name of Azure region. Required. + :type location: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10781,205 +10352,53 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_list_publishers_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. + def list_offers( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image offers for the specified location and publisher. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :param extension_parameters: Parameters supplied to the Update VM scale set Extension - operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. - Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10992,12 +10411,11 @@ def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_list_offers_request( + location=location, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -11005,23 +10423,18 @@ def _delete_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11029,85 +10442,19 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace - def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. - Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get the extension. + def list_skus( + self, location: str, publisher_name: str, offer: str, **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. - :type vm_scale_set_name: str - :param vmss_extension_name: The name of the VM scale set extension. Required. - :type vmss_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11122,14 +10469,13 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_extensions_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + _request = build_virtual_machine_images_list_skus_request( + location=location, + publisher_name=publisher_name, + offer=offer, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -11147,7 +10493,7 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11156,25 +10502,189 @@ def get( @distributed_trace def list( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtension"]: - """Gets a list of all extensions in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. - :type vm_scale_set_name: str - :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of - cls(response) + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, publisher, offer, + and SKU. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineImageResource or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _request = build_virtual_machine_images_list_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineImage: + """Gets a virtual machine image. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :param version: A valid image SKU version. Required. + :type version: str + :return: VirtualMachineImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + + _request = build_virtual_machine_images_get_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, + version=version, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_with_properties( + self, + location: str, + publisher_name: str, + offer: str, + skus: str, + *, + expand: Union[str, _models.Expand], + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineImage"]: + """list_with_properties. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: A valid image publisher. Required. + :type publisher_name: str + :param offer: A valid image publisher offer. Required. + :type offer: str + :param skus: A valid image SKU. Required. + :type skus: str + :keyword expand: The expand expression to apply on the operation. "Properties" Required. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.Expand + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: An iterator like instance of either VirtualMachineImage or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineImagesWithPropertiesListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11187,10 +10697,15 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_set_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_images_list_with_properties_request( + location=location, + publisher_name=publisher_name, + offer=offer, + skus=skus, subscription_id=self._config.subscription_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -11215,7 +10730,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineImagesWithPropertiesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -11239,14 +10754,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long +class LogAnalyticsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + :attr:`log_analytics` attribute. """ models = _models @@ -11259,7 +10774,9 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: + def _export_request_rate_by_interval_initial( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11268,17 +10785,28 @@ def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kw } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RequestRateByIntervalInput") + + _request = build_log_analytics_export_request_rate_by_interval_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -11300,38 +10828,103 @@ def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kw map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_cancel(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> LROPoller[None]: - """Cancels the current virtual machine scale set rolling upgrade. + @overload + def begin_export_request_rate_by_interval( + self, + location: str, + parameters: _models.RequestRateByIntervalInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + def begin_export_request_rate_by_interval( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export_request_rate_by_interval( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show Api requests made by this subscription in the given time window to show + throttling activities. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is + either a RequestRateByIntervalInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput or + IO[bytes] + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + raw_result = self._export_request_rate_by_interval_initial( + location=location, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -11340,27 +10933,33 @@ def begin_cancel(self, resource_group_name: str, vm_scale_set_name: str, **kwarg raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.LogAnalyticsOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + def _export_throttled_requests_initial( + self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11370,17 +10969,28 @@ def _start_os_upgrade_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ThrottledRequestsInput") + + _request = build_log_analytics_export_throttled_requests_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -11402,42 +11012,100 @@ def _start_os_upgrade_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_export_throttled_requests( + self, + location: str, + parameters: _models.ThrottledRequestsInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_throttled_requests( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. + + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_start_os_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all virtual machine scale set instances to the latest - available Platform Image OS version. Instances which are already running the latest available - OS version are not affected. + def begin_export_throttled_requests( + self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.LogAnalyticsOperationResult]: + """Export logs that show total throttled Api requests for this subscription in the given time + window. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :param parameters: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_os_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + raw_result = self._export_throttled_requests_initial( + location=location, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -11446,28 +11114,66 @@ def begin_start_os_upgrade( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.LogAnalyticsOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _start_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_types( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image types. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11480,11 +11186,11 @@ def _start_extension_upgrade_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_extension_images_list_types_request( + location=location, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -11492,23 +11198,18 @@ def _start_extension_upgrade_initial( ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11516,73 +11217,97 @@ def _start_extension_upgrade_initial( return deserialized # type: ignore @distributed_trace - def begin_start_extension_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to - the latest available extension version. Instances which are already running the latest - extension versions are not affected. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + def list_versions( + self, + location: str, + publisher_name: str, + type: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image versions. + + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :param type: Required. + :type type: str + :keyword filter: The filter to apply on the operation. Default value is None. + :paramtype filter: str + :keyword top: Default value is None. + :paramtype top: int + :keyword orderby: Default value is None. + :paramtype orderby: str + :return: list of VirtualMachineExtensionImage or the result of cls(response) + :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_extension_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + _request = build_virtual_machine_extension_images_list_versions_request( + location=location, + publisher_name=publisher_name, + type=type, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + orderby=orderby, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def get_latest( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> _models.RollingUpgradeStatusInfo: - """Gets the status of the latest virtual machine scale set rolling upgrade. + def get( + self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineExtensionImage: + """Gets a virtual machine extension image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :return: RollingUpgradeStatusInfo or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo + :param location: The name of Azure region. Required. + :type location: str + :param publisher_name: Required. + :type publisher_name: str + :param type: Required. + :type type: str + :param version: Required. + :type version: str + :return: VirtualMachineExtensionImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11597,11 +11322,13 @@ def get_latest( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + _request = build_virtual_machine_extension_images_get_request( + location=location, + publisher_name=publisher_name, + type=type, + version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -11620,7 +11347,7 @@ def get_latest( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RollingUpgradeStatusInfo", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineExtensionImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11628,14 +11355,14 @@ def get_latest( return deserialized # type: ignore -class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long +class VirtualMachineRunCommandsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. + :attr:`virtual_machine_run_commands` attribute. """ models = _models @@ -11648,15 +11375,24 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - def _create_or_update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def list(self, location: str, **kwargs: Any) -> Iterable["_models.RunCommandDocumentBase"]: + """Lists all available run commands for a subscription in a location. + + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either RunCommandDocumentBase or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11665,218 +11401,71 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _request = build_virtual_machine_run_commands_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _request = build_virtual_machine_scale_set_vm_extensions_create_or_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def extract_data(pipeline_response): + deserialized = self._deserialize("RunCommandListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def get_next(next_link=None): + _request = prepare_request(next_link) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + return pipeline_response - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return ItemPaged(get_next, extract_data) - return deserialized # type: ignore + @distributed_trace + def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: + """Gets specific run command for a subscription in a location. - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :param location: The name of Azure region. Required. + :type location: str + :param command_id: The command id. Required. + :type command_id: str + :return: RunCommandDocument or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVMExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11885,38 +11474,23 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") + cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + _request = build_virtual_machine_run_commands_get_request( + location=location, + command_id=command_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -11924,173 +11498,180 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("RunCommandDocument", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + @distributed_trace + def list_by_virtual_machine( + self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands of a Virtual Machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_update( + def get_by_virtual_machine( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + vm_name: str, + run_command_name: str, + *, + expand: Optional[str] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to update the VMSS VM extension. + ) -> _models.VirtualMachineRunCommand: + """The operation to get the run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _request = build_virtual_machine_run_commands_get_by_virtual_machine_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualMachineScaleSetVMExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12100,19 +11681,30 @@ def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + + _request = build_virtual_machine_run_commands_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -12126,7 +11718,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -12134,46 +11726,128 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete the VMSS VM extension. + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: _models.VirtualMachineRunCommand, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + Required. + :type run_command: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to create or update the run command. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is + either a VirtualMachineRunCommand type or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + vm_name=vm_name, + run_command_name=run_command_name, + run_command=run_command, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -12182,52 +11856,39 @@ def begin_delete( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - @distributed_trace - def get( + def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtension: - """The operation to get the VMSS VM extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12236,26 +11897,37 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(run_command, (IOBase, bytes)): + _content = run_command + else: + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + + _request = build_virtual_machine_run_commands_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_extension_name=vm_extension_name, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -12263,116 +11935,175 @@ def get( response = pipeline_response.http_response if response.status_code not in [200]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( + @overload + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, + vm_name: str, + run_command_name: str, + run_command: _models.VirtualMachineRunCommandUpdate, *, - expand: Optional[str] = None, + content_type: str = "application/json", **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: - """The operation to get all extensions of an instance in Virtual Machine Scaleset. + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. - _request = build_virtual_machine_scale_set_vm_extensions_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + Required. + :type run_command: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize( - "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + @distributed_trace + def begin_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineRunCommand]: + """The operation to update the run command. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is + either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. + :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + run_command_name=run_command_name, + run_command=run_command, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - models = _models + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineRunCommand]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _reimage_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any + def _delete_initial( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12382,33 +12113,18 @@ def _reimage_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): - _content = vm_scale_set_vm_reimage_input - else: - if vm_scale_set_vm_reimage_input is not None: - _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") - else: - _json = None - - _request = build_virtual_machine_scale_set_vms_reimage_request( + _request = build_virtual_machine_run_commands_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_name=vm_name, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -12422,7 +12138,7 @@ def _reimage_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -12430,119 +12146,49 @@ def _reimage_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Default value is None. - :type vm_scale_set_vm_reimage_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_reimage( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. + """The operation to delete the run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. - Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value - is None. - :type vm_scale_set_vm_reimage_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] + :param vm_name: The name of the VirtualMachine. Required. + :type vm_name: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._delete_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, + vm_name=vm_name, + run_command_name=run_command_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -12556,7 +12202,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -12570,118 +12218,44 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _reimage_all_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`usage` attribute. + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + models = _models - return deserialized # type: ignore + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. - This operation is only supported for managed disks. + def list(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: + """Gets, for the specified location, the current compute resource usage information as well as the + limits for compute resources under the subscription. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._reimage_all_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) - def _approve_rolling_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12690,109 +12264,177 @@ def _approve_rolling_upgrade_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _request = build_usage_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("ListUsagesResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + return pipeline_response - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return ItemPaged(get_next, extract_data) - return deserialized # type: ignore + +class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_approve_rolling_upgrade( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Approve upgrade on deferred rolling upgrade for OS disk on a VM scale set instance. + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: + """Gets all the VM scale sets under the specified subscription for the specified location. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._approve_rolling_upgrade_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_sets_list_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this + till nextLink is null to fetch all the VM Scale Sets. + + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12801,116 +12443,77 @@ def _deallocate_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _request = build_virtual_machine_scale_sets_list_all_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_scale_set_vms_deallocate_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListWithLinkResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_deallocate( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and - releases the compute resources it uses. You are not billed for the compute resources of this - virtual machine once it is deallocated. + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: + """Gets a list of all VM scale sets under a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._deallocate_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) - def _update_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12919,35 +12522,172 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") + _request = build_virtual_machine_scale_sets_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_scale_set_vms_update_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + *, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSet: + """Display information about a virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the + UserData property of the VM scale set that was provided by the user during the VM scale set + Create/Update operation. "userData" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_sets_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSet") + + _request = build_virtual_machine_scale_sets_create_or_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) @@ -12958,7 +12698,7 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -12966,38 +12706,39 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, + parameters: _models.VirtualMachineScaleSet, *, if_match: Optional[str] = None, if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -13009,37 +12750,33 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, parameters: IO[bytes], *, if_match: Optional[str] = None, if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Required. + :param parameters: The scale set object. Required. :type parameters: IO[bytes] :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting @@ -13052,37 +12789,34 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], *, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set where the extension should be create or - updated. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. - Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] + :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet or IO[bytes] :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the current resource. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -13091,10 +12825,10 @@ def begin_update( updating an existing record set. Other values will result in error from server as they are not supported. Default value is None. :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -13102,15 +12836,14 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, parameters=parameters, if_match=if_match, if_none_match=if_none_match, @@ -13125,35 +12858,38 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineScaleSetVM]( + return LROPoller[_models.VirtualMachineScaleSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( + def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], *, - force_deletion: Optional[bool] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -13164,21 +12900,33 @@ def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") + + _request = build_virtual_machine_scale_sets_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, ) _request.url = self._client.format_url(_request.url) @@ -13190,7 +12938,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -13198,53 +12946,149 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: _models.VirtualMachineScaleSetUpdate, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The scale set object. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_delete( + def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], *, - force_deletion: Optional[bool] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a virtual machine from a VM scale set. + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Update a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword force_deletion: Optional parameter to force delete a virtual machine from a VM scale - set. (Feature in Preview). Default value is None. - :paramtype force_deletion: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetUpdate or + IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - force_deletion=force_deletion, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -13253,53 +13097,39 @@ def begin_delete( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetVM: - """Gets a virtual machine from a VM scale set. + return LROPoller[_models.VirtualMachineScaleSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual - machine. 'resiliencyView' will retrieve the instance view of the Virtual machine (if - applicable) and include 'resilientVMDeletionStatus' as part of it. Known values are: - "instanceView", "userData", and "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13312,286 +13142,63 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_get_request( + _request = build_virtual_machine_scale_sets_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def get_instance_view( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMInstanceView: - """Gets the status of a virtual machine from a VM scale set. + def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: VirtualMachineScaleSetVMInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_get_instance_view_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - resource_group_name: str, - virtual_machine_scale_set_name: str, - *, - filter: Optional[str] = None, - select: Optional[str] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVM"]: - """Gets a list of all virtual machines in a VM scale sets. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param virtual_machine_scale_set_name: The name of the VM scale set. Required. - :type virtual_machine_scale_set_name: str - :keyword filter: The filter to apply to the operation. Allowed values are - 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied - eq true', 'properties/latestModelApplied eq false'. Default value is None. - :paramtype filter: str - :keyword select: The list parameters. Allowed values are 'instanceView', - 'instanceView/statuses'. Default value is None. - :paramtype select: str - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'instanceView'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vms_list_request( - resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_power_off_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **kwargs: Any - ) -> LROPoller[None]: - """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached - and you are getting charged for the resources. Instead, use deallocate to release resources and - avoid charges. Additionally, this operation is not allowed on a virtual machine that is being - deallocated or already has been deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :keyword force_deletion: Optional parameter to force delete a VM scale set. (Feature in + Preview). Default value is None. + :paramtype force_deletion: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} @@ -13603,11 +13210,10 @@ def begin_power_off( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._power_off_initial( + raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - skip_shutdown=skip_shutdown, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -13622,7 +13228,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -13636,8 +13244,12 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _restart_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + def _approve_rolling_upgrade_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13647,18 +13259,32 @@ def _restart_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_restart_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_approve_rolling_upgrade_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -13672,7 +13298,7 @@ def _restart_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -13680,43 +13306,116 @@ def _restart_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_restart( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Restarts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. + @overload + def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_approve_rolling_upgrade( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._approve_rolling_upgrade_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -13730,7 +13429,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -13744,8 +13445,143 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + @overload + def convert_to_single_placement_group( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. + :type parameters: + ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def convert_to_single_placement_group( + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def convert_to_single_placement_group( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vm_scale_set_name: str, + parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], + **kwargs: Any + ) -> None: + """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a + VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. + :type parameters: + ~azure.mgmt.compute.v2024_11_01.models.VMScaleSetConvertToSinglePlacementGroupInput or + IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") + + _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _deallocate_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + hibernate: Optional[bool] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13755,18 +13591,33 @@ def _start_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_start_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_deallocate_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + hibernate=hibernate, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -13788,43 +13639,137 @@ def _start_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str + @overload + def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + hibernate: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + hibernate: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_deallocate( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + hibernate: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and + releases the compute resources. You are not billed for the compute resources that this virtual + machine scale set deallocates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :keyword hibernate: Optional parameter to hibernate a virtual machine from the VM scale set. + (This feature is available for VMSS with Flexible OrchestrationMode only). Default value is + None. + :paramtype hibernate: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_initial( + raw_result = self._deallocate_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_instance_i_ds=vm_instance_i_ds, + hibernate=hibernate, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -13838,7 +13783,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -13852,8 +13799,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + def _delete_instances_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13863,18 +13816,30 @@ def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_redeploy_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + + _request = build_virtual_machine_scale_sets_delete_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -13896,44 +13861,128 @@ def _redeploy_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_delete_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + *, + force_deletion: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deletes virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_delete_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: IO[bytes], + *, + force_deletion: Optional[bool] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Deletes virtual machines in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: IO[bytes] + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_redeploy( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + def begin_delete_instances( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> LROPoller[None]: - """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and - powers it back on. + """Deletes virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] + :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._redeploy_initial( + raw_result = self._delete_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, + vm_instance_i_ds=vm_instance_i_ds, + force_deletion=force_deletion, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -13947,7 +13996,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -13962,30 +14013,35 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def retrieve_boot_diagnostics_data( + def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, + platform_update_domain: int, + zone: Optional[str] = None, + placement_group_id: Optional[str] = None, **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale - set. + ) -> _models.RecoveryWalkResponse: + """Manual platform update domain walk to update virtual machines in a service fabric virtual + machine scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult + :keyword platform_update_domain: The platform update domain for which a manual recovery walk is + requested. Required. + :paramtype platform_update_domain: int + :keyword zone: The zone in which the manual recovery walk is requested for cross zone virtual + machine scale set. Default value is None. + :paramtype zone: str + :keyword placement_group_id: The placement group id for which the manual recovery walk is + requested. Default value is None. + :paramtype placement_group_id: str + :return: RecoveryWalkResponse or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RecoveryWalkResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14000,14 +14056,15 @@ def retrieve_boot_diagnostics_data( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( + _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, + platform_update_domain=platform_update_domain, + zone=zone, + placement_group_id=placement_group_id, api_version=api_version, headers=_headers, params=_params, @@ -14025,58 +14082,7 @@ def retrieve_boot_diagnostics_data( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _perform_maintenance_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14084,76 +14090,18 @@ def _perform_maintenance_initial( return deserialized # type: ignore @distributed_trace - def begin_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._perform_maintenance_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine in a VM scale set. + def get_instance_view( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.VirtualMachineScaleSetInstanceView: + """Gets the status of a VM scale set instance. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :return: None or the result of cls(response) - :rtype: None + :return: VirtualMachineScaleSetInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14168,12 +14116,11 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( + _request = build_virtual_machine_scale_sets_get_instance_view_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -14188,19 +14135,22 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - def _attach_detach_data_disks_initial( + return deserialized # type: ignore + + def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14221,15 +14171,14 @@ def _attach_detach_data_disks_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( + _request = build_virtual_machine_scale_sets_update_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -14259,6 +14208,7 @@ def _attach_detach_data_disks_initial( response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -14268,92 +14218,83 @@ def _attach_detach_data_disks_initial( return deserialized # type: ignore @overload - def begin_attach_detach_data_disks( + def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.AttachDetachDataDisksRequest, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_attach_detach_data_disks( + def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_instance_i_ds: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: IO[bytes] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. + Required. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_attach_detach_data_disks( + def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Is either a AttachDetachDataDisksRequest type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -14361,16 +14302,15 @@ def begin_attach_detach_data_disks( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._attach_detach_data_disks_initial( + raw_result = self._update_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -14381,11 +14321,9 @@ def begin_attach_detach_data_disks( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -14396,22 +14334,104 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.StorageProfile].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.StorageProfile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _run_command_initial( + @distributed_trace + def get_os_upgrade_history( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterable["_models.UpgradeOperationHistoricalStatusInfo"]: + """Gets list of OS upgrades on a VM scale set instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.UpgradeOperationHistoricalStatusInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14432,15 +14452,17 @@ def _run_command_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "RunCommandInput") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machine_scale_set_vms_run_command_request( + _request = build_virtual_machine_scale_sets_perform_maintenance_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -14467,96 +14489,105 @@ def _run_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_run_command( + def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.RunCommandInput, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_run_command( + def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_run_command( + def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> LROPoller[None]: + """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances + which are not eligible for perform maintenance will be failed. Please refer to best practices + for more details: + https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -14564,16 +14595,15 @@ def begin_run_command( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._run_command_initial( + raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -14584,11 +14614,9 @@ def begin_run_command( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -14599,43 +14627,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_or_update_initial( + def _power_off_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14656,16 +14662,19 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machine_extensions_create_or_update_request( + _request = build_virtual_machine_scale_sets_power_off_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, json=_json, @@ -14683,7 +14692,7 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -14691,105 +14700,118 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update( + def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtension, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, + skip_shutdown: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, + skip_shutdown: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_power_off( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> LROPoller[None]: + """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still + attached and you are getting charged for the resources. Instead, use deallocate to release + resources and avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be created or - updated. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension - operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. - :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -14797,16 +14819,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._power_off_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -14817,37 +14839,28 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineExtension].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _update_initial( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14856,30 +14869,17 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(extension_parameters, (IOBase, bytes)): - _content = extension_parameters - else: - _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - - _request = build_virtual_machine_extensions_update_request( + _request = build_virtual_machine_scale_sets_reapply_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -14893,7 +14893,7 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -14901,106 +14901,229 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + @distributed_trace + def begin_reapply(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> LROPoller[None]: + """Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine + Instances. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_update( + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reapply_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _redeploy_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_redeploy_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_redeploy( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_redeploy( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Required. - :type extension_parameters: IO[bytes] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_redeploy( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> LROPoller[None]: + """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, + and powers them back on. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -15008,16 +15131,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._redeploy_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, - extension_parameters=extension_parameters, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -15028,31 +15150,33 @@ def begin_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineExtension].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineExtension]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any + def _reimage_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15062,18 +15186,32 @@ def _delete_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_extensions_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_reimage_input + else: + if vm_scale_set_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") + else: + _json = None + + _request = build_virtual_machine_scale_sets_reimage_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -15087,7 +15225,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -15095,44 +15233,118 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_delete( - self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any + @overload + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the extension. + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the extension should be deleted. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. + :type vm_scale_set_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + @overload + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. + :type vm_scale_set_reimage_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which + don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual + machine is reset to initial state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a + VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. + :type vm_scale_set_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._reimage_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, + vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -15146,7 +15358,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -15160,30 +15374,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def get( + def _reimage_all_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> _models.VirtualMachineExtension: - """The operation to get the extension. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :param vm_extension_name: The name of the virtual machine extension. Required. - :type vm_extension_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtension or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15192,205 +15389,198 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_extensions_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds + else: + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None + + _request = build_virtual_machine_scale_sets_reimage_all_request( resource_group_name=resource_group_name, - vm_name=vm_name, - vm_extension_name=vm_extension_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.VirtualMachineExtensionsListResult: - """The operation to get all extensions of a Virtual Machine. + @overload + def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the extension. Required. - :type vm_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - - _request = build_virtual_machine_extensions_list_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) + @overload + def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ - return deserialized # type: ignore + @distributed_trace + def begin_reimage_all( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This + operation is only supported for managed disks. - -class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: - """Gets all the virtual machines under the specified subscription for the specified location. - - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_by_location_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _capture_initial( + def _restart_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -15411,14 +15601,17 @@ def _capture_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machines_capture_request( + _request = build_virtual_machine_scale_sets_restart_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -15445,94 +15638,96 @@ def _capture_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_capture( + def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineCaptureParameters, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> LROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_capture( + def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> LROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_capture( + def begin_restart( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineCaptureResult]: - """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used - to create similar VMs. + ) -> LROPoller[None]: + """Restarts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a - VirtualMachineCaptureParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -15540,15 +15735,15 @@ def begin_capture( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._capture_initial( + raw_result = self._restart_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -15559,11 +15754,9 @@ def begin_capture( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -15574,24 +15767,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineCaptureResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineCaptureResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_or_update_initial( + def _set_orchestration_service_state_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -15615,14 +15803,12 @@ def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VirtualMachine") + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") - _request = build_virtual_machines_create_or_update_request( + _request = build_virtual_machine_scale_sets_set_orchestration_service_state_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -15640,7 +15826,7 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -15648,121 +15834,93 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create_or_update( + def begin_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachine, + vm_scale_set_name: str, + parameters: _models.OrchestrationServiceStateInput, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> LROPoller[None]: + """Changes ServiceState property for a given service. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, parameters: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> LROPoller[None]: + """Changes ServiceState property for a given service. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Required. :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachine, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> LROPoller[None]: + """Changes ServiceState property for a given service. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param parameters: The input object for SetOrchestrationServiceState API. Is either a + OrchestrationServiceStateInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.OrchestrationServiceStateInput or + IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -15770,17 +15928,15 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._set_orchestration_service_state_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -15791,37 +15947,118 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachine].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachine]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _update_initial( + @distributed_trace + def list_skus( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachineScaleSetSku"]: + """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM + instances allowed for each SKU. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_sets_list_skus_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _start_initial( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -15842,17 +16079,18 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(vm_instance_i_ds, (IOBase, bytes)): + _content = vm_instance_i_ds else: - _json = self._serialize.body(parameters, "VirtualMachineUpdate") + if vm_instance_i_ds is not None: + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") + else: + _json = None - _request = build_virtual_machines_update_request( + _request = build_virtual_machine_scale_sets_start_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - if_match=if_match, - if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -15870,7 +16108,7 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -15878,118 +16116,96 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_start( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineUpdate, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> LROPoller[None]: + """Starts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_start( self, resource_group_name: str, - vm_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vm_instance_i_ds: Optional[IO[bytes]] = None, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> LROPoller[None]: + """Starts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. - :type parameters: IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default + value is None. + :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_start( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], - *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> LROPoller[None]: + """Starts one or more virtual machines in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a - VirtualMachineUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate or IO[bytes] - :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the - current resource. Specify the last-seen ETag value to prevent accidentally overwriting - concurrent changes. Default value is None. - :paramtype if_match: str - :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent - updating an existing record set. Other values will result in error from server as they are not - supported. Default value is None. - :paramtype if_none_match: str - :return: An instance of LROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -15997,17 +16213,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._start_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - parameters=parameters, - if_match=if_match, - if_none_match=if_none_match, + vm_scale_set_name=vm_scale_set_name, + vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -16018,143 +16232,320 @@ def begin_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachine].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachine]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machines_delete_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - force_deletion=force_deletion, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) +class VirtualMachinesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + models = _models - return deserialized # type: ignore + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def begin_delete( - self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[None]: - """The operation to delete a virtual machine. + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: + """Gets all the virtual machines under the specified subscription for the specified location. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :keyword force_deletion: Optional parameter to force delete virtual machines. - NOTE: As of api-version 2024-11-01, we are rolling out a feature where if the forceDeletion - parameter is unspecified OR not explicitly set to false, AND all of the VM's attached disks - including the OS disk are marked with the delete option, then the VM will be force deleted. For - more details on how to configure delete options for a VM's resources, see `Delete a VM and - attached resources `_. To - avoid defaulting to force delete, ensure that the forceDeletion parameter is explicitly set to - false. This feature is expected to rollout by end of March 2025. Default value is None. - :paramtype force_deletion: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param location: The name of Azure region. Required. + :type location: str + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - force_deletion=force_deletion, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machines_list_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_all( + self, + *, + status_only: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualMachine"]: + # pylint: disable=line-too-long + """Lists all of the virtual machines in the specified subscription. Use the nextLink property in + the response to get the next page of virtual machines. + + :keyword status_only: statusOnly=true enables fetching run time status of all Virtual Machines + in the subscription. Default value is None. + :paramtype status_only: str + :keyword filter: The system query option to filter VMs returned in the response. Allowed value + is 'virtualMachineScaleSet/id' eq + /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. + Default value is None. + :paramtype filter: str + :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching + run time status of all Virtual Machines, this can only be specified if a valid $filter option + is specified. "instanceView" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machines_list_all_request( + subscription_id=self._config.subscription_id, + status_only=status_only, + filter=filter, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list( + self, + resource_group_name: str, + *, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualMachine"]: + # pylint: disable=line-too-long + """Lists all of the virtual machines in the specified resource group. Use the nextLink property in + the response to get the next page of virtual machines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword filter: The system query option to filter VMs returned in the response. Allowed value + is 'virtualMachineScaleSet/id' eq + /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. + Default value is None. + :paramtype filter: str + :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching + run time status of all Virtual Machines, this can only be specified if a valid $filter option + is specified. "instanceView" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machines_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get( @@ -16167,7 +16558,8 @@ def get( ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str @@ -16224,64 +16616,15 @@ def get( return deserialized # type: ignore - @distributed_trace - def instance_view( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> _models.VirtualMachineInstanceView: - """Retrieves information about the run-time state of a virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: VirtualMachineInstanceView or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - - _request = build_virtual_machines_instance_view_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _convert_to_managed_disks_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any + def _create_or_update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16291,17 +16634,31 @@ def _convert_to_managed_disks_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_convert_to_managed_disks_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachine") + + _request = build_virtual_machines_create_or_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -16315,7 +16672,7 @@ def _convert_to_managed_disks_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -16323,39 +16680,149 @@ def _convert_to_managed_disks_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachine, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_convert_to_managed_disks(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be - stop-deallocated before invoking this operation. + def begin_create_or_update( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachine, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to create or update a virtual machine. Please note some properties can be set + only during virtual machine creation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a + VirtualMachine type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachine or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._convert_to_managed_disks_initial( + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -16364,27 +16831,40 @@ def begin_convert_to_managed_disks(self, resource_group_name: str, vm_name: str, raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _deallocate_initial( - self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + def _update_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16394,18 +16874,31 @@ def _deallocate_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_deallocate_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineUpdate") + + _request = build_virtual_machines_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, - hibernate=hibernate, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -16419,7 +16912,7 @@ def _deallocate_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -16427,44 +16920,145 @@ def _deallocate_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineUpdate, + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_deallocate( - self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[None]: - """Shuts down the virtual machine and releases the compute resources. You are not billed for the - compute resources that this virtual machine uses. + def begin_update( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """The operation to update a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :keyword hibernate: Optional parameter to hibernate a virtual machine. Default value is None. - :paramtype hibernate: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a + VirtualMachineUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineUpdate or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of LROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._deallocate_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, - hibernate=hibernate, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -16473,44 +17067,39 @@ def begin_deallocate( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def generalize( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> None: - """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the - virtual machine before performing this operation. For Windows, please refer to `Create a - managed image of a generalized VM in Azure - `_. For - Linux, please refer to `How to create an image of a virtual machine or VHD - `_. + return LROPoller[_models.VirtualMachine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -16523,313 +17112,109 @@ def generalize( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_generalize_request( + _request = build_virtual_machines_delete_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - *, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, - **kwargs: Any - ) -> Iterable["_models.VirtualMachine"]: - # pylint: disable=line-too-long - """Lists all of the virtual machines in the specified resource group. Use the nextLink property in - the response to get the next page of virtual machines. + def begin_delete( + self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypeForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :keyword force_deletion: Optional parameter to force delete virtual machines. Default value is + None. + :paramtype force_deletion: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + force_deletion=force_deletion, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def prepare_request(next_link=None): - if not next_link: + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - _request = build_virtual_machines_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_all( - self, - *, - status_only: Optional[str] = None, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, - **kwargs: Any - ) -> Iterable["_models.VirtualMachine"]: - # pylint: disable=line-too-long - """Lists all of the virtual machines in the specified subscription. Use the nextLink property in - the response to get the next page of virtual machines. - - :keyword status_only: statusOnly=true enables fetching run time status of all Virtual Machines - in the subscription. Default value is None. - :paramtype status_only: str - :keyword filter: The system query option to filter VMs returned in the response. Allowed value - is 'virtualMachineScaleSet/id' eq - /subscriptions/{subId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}'. - Default value is None. - :paramtype filter: str - :keyword expand: The expand expression to apply on operation. 'instanceView' enables fetching - run time status of all Virtual Machines, this can only be specified if a valid $filter option - is specified. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_all_request( - subscription_id=self._config.subscription_id, - status_only=status_only, - filter=filter, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes to which the specified virtual machine can be - resized. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machines_list_available_sizes_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> Iterator[bytes]: + def _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -16844,11 +17229,10 @@ def _power_off_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_power_off_request( + _request = build_virtual_machines_assess_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, - skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, @@ -16871,47 +17255,47 @@ def _power_off_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_power_off( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any - ) -> LROPoller[None]: - """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with - the same provisioned resources. You are still charged for this virtual machine. NOTE: This - operation is not allowed on a virtual machine that is being deallocated or has already been - deallocated. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. + def begin_assess_patches( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: + """Assess patches on the VM. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this - flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this - flag is false if not specified. Default value is False. - :paramtype skip_shutdown: bool - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAssessPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineAssessPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._power_off_initial( + raw_result = self._assess_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, - skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -16921,26 +17305,38 @@ def begin_power_off( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineAssessPatchesResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _attach_detach_data_disks_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -16949,17 +17345,29 @@ def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_reapply_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + + _request = build_virtual_machines_attach_detach_data_disks_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -16981,38 +17389,116 @@ def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.AttachDetachDataDisksRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to reapply a virtual machine's state. + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or + IO[bytes] + :return: An instance of LROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reapply_initial( + raw_result = self._attach_detach_data_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -17021,26 +17507,38 @@ def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) - raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.StorageProfile].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.StorageProfile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _capture_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17049,17 +17547,29 @@ def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_restart_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") + + _request = build_virtual_machines_capture_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -17081,66 +17591,156 @@ def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to restart a virtual machine. + @overload + def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.VirtualMachineCaptureParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restart_initial( - resource_group_name=resource_group_name, - vm_name=vm_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + @overload + def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_capture( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineCaptureResult]: + """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used + to create similar VMs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a + VirtualMachineCaptureParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureParameters or + IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._capture_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineCaptureResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineCaptureResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _convert_to_managed_disks_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17155,7 +17755,7 @@ def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_start_request( + _request = build_virtual_machines_convert_to_managed_disks_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17181,18 +17781,25 @@ def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to start a virtual machine. + def begin_convert_to_managed_disks(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be + stop-deallocated before invoking this operation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str @@ -17209,7 +17816,7 @@ def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_initial( + raw_result = self._convert_to_managed_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -17226,7 +17833,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -17240,7 +17849,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _deallocate_initial( + self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17255,10 +17866,11 @@ def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: An api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_redeploy_request( + _request = build_virtual_machines_deallocate_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + hibernate=hibernate, api_version=api_version, headers=_headers, params=_params, @@ -17281,21 +17893,32 @@ def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: An map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """Shuts down the virtual machine, moves it to a new node, and powers it back on. + def begin_deallocate( + self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: + """Shuts down the virtual machine and releases the compute resources. You are not billed for the + compute resources that this virtual machine uses. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str + :keyword hibernate: Optional parameter to hibernate a virtual machine. Default value is None. + :paramtype hibernate: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -17309,9 +17932,10 @@ def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._redeploy_initial( + raw_result = self._deallocate_initial( resource_group_name=resource_group_name, vm_name=vm_name, + hibernate=hibernate, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -17326,7 +17950,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -17340,11 +17966,69 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _reimage_initial( + @distributed_trace + def generalize( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> None: + """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the + virtual machine before performing this operation. For Windows, please refer to `Create a + managed image of a generalized VM in Azure + `_. For + Linux, please refer to `How to create an image of a virtual machine or VHD + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_virtual_machines_generalize_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _install_patches_initial( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -17365,15 +18049,12 @@ def _reimage_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(install_patches_input, (IOBase, bytes)): + _content = install_patches_input else: - if parameters is not None: - _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") - else: - _json = None + _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - _request = build_virtual_machines_reimage_request( + _request = build_virtual_machines_install_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17402,102 +18083,102 @@ def _reimage_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_reimage( + def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_reimage( + def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: Optional[IO[bytes]] = None, + install_patches_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value - is None. - :type parameters: IO[bytes] + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_reimage( + def begin_install_patches( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, - for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial - state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If - deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is - delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should - be updated accordingly before performing the reimage. + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """Installs patches on the VM. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a - VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or - IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -17505,15 +18186,15 @@ def begin_reimage( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineInstallPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._install_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, + install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -17524,46 +18205,44 @@ def begin_reimage( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[None].from_continuation_token( + return LROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[_models.VirtualMachineInstallPatchesResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def retrieve_boot_diagnostics_data( - self, - resource_group_name: str, - vm_name: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, - **kwargs: Any - ) -> _models.RetrieveBootDiagnosticsDataResult: - """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. + def instance_view( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> _models.VirtualMachineInstanceView: + """Retrieves information about the run-time state of a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs - with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated - with a default expiration duration of 120 minutes. Default value is None. - :paramtype sas_uri_expiration_time_in_minutes: int - :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult + :return: VirtualMachineInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -17578,13 +18257,12 @@ def retrieve_boot_diagnostics_data( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( + _request = build_virtual_machines_instance_view_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, - sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, headers=_headers, params=_params, @@ -17602,14 +18280,20 @@ def retrieve_boot_diagnostics_data( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _migrate_to_vm_scale_set_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17618,17 +18302,32 @@ def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, * } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_perform_maintenance_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "MigrateVMToVirtualMachineScaleSetInput") + else: + _json = None + + _request = build_virtual_machines_migrate_to_vm_scale_set_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -17642,7 +18341,7 @@ def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, * response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -17650,38 +18349,112 @@ def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, * map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: - """The operation to perform maintenance on a virtual machine. + def begin_migrate_to_vm_scale_set( + self, + resource_group_name: str, + vm_name: str, + parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str + :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a + MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput + or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._perform_maintenance_initial( + raw_result = self._migrate_to_vm_scale_set_initial( resource_group_name=resource_group_name, vm_name=vm_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -17695,7 +18468,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -17709,59 +18484,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def simulate_eviction( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> None: - """The operation to simulate the eviction of spot virtual machine. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_virtual_machines_simulate_eviction_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17776,7 +18499,7 @@ def _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_assess_patches_request( + _request = build_virtual_machines_perform_maintenance_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17802,39 +18525,41 @@ def _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwar map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_assess_patches( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. + def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to perform maintenance on a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineAssessPatchesResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineAssessPatchesResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._assess_patches_initial( + raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -17846,11 +18571,9 @@ def begin_assess_patches( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -17861,22 +18584,16 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineAssessPatchesResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _install_patches_initial( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any + def _power_off_initial( + self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -17886,29 +18603,18 @@ def _install_patches_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input - else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") - - _request = build_virtual_machines_install_patches_request( + _request = build_virtual_machines_power_off_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -17930,112 +18636,52 @@ def _install_patches_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - Required. - :type install_patches_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_install_patches( - self, - resource_group_name: str, - vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + def begin_power_off( + self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: + """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with + the same provisioned resources. You are still charged for this virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. Is - either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineInstallPatchesResult] + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineInstallPatchesResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_patches_initial( + raw_result = self._power_off_initial( resource_group_name=resource_group_name, vm_name=vm_name, - install_patches_input=install_patches_input, + skip_shutdown=skip_shutdown, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -18044,11 +18690,9 @@ def begin_install_patches( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -18059,23 +18703,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineInstallPatchesResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _attach_detach_data_disks_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18084,29 +18720,17 @@ def _attach_detach_data_disks_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - - _request = build_virtual_machines_attach_detach_data_disks_request( + _request = build_virtual_machines_reapply_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -18131,6 +18755,7 @@ def _attach_detach_data_disks_initial( response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -18139,101 +18764,140 @@ def _attach_detach_data_disks_initial( return deserialized # type: ignore - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.AttachDetachDataDisksRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + @distributed_trace + def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to reapply a virtual machine's state. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reapply_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_machines_redeploy_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """Shuts down the virtual machine, moves it to a new node, and powers it back on. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Is either a AttachDetachDataDisksRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or - IO[bytes] - :return: An instance of LROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._attach_detach_data_disks_initial( + raw_result = self._redeploy_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -18242,11 +18906,9 @@ def begin_attach_detach_data_disks( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -18257,21 +18919,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.StorageProfile].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.StorageProfile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _migrate_to_vm_scale_set_initial( + def _reimage_initial( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -18296,11 +18956,11 @@ def _migrate_to_vm_scale_set_initial( _content = parameters else: if parameters is not None: - _json = self._serialize.body(parameters, "MigrateVMToVirtualMachineScaleSetInput") + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") else: _json = None - _request = build_virtual_machines_migrate_to_vm_scale_set_request( + _request = build_virtual_machines_reimage_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -18321,7 +18981,7 @@ def _migrate_to_vm_scale_set_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -18329,32 +18989,43 @@ def _migrate_to_vm_scale_set_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_migrate_to_vm_scale_set( + def begin_reimage( self, resource_group_name: str, vm_name: str, - parameters: Optional[_models.MigrateVMToVirtualMachineScaleSetInput] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -18364,7 +19035,7 @@ def begin_migrate_to_vm_scale_set( """ @overload - def begin_migrate_to_vm_scale_set( + def begin_reimage( self, resource_group_name: str, vm_name: str, @@ -18373,13 +19044,19 @@ def begin_migrate_to_vm_scale_set( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Default value + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value is None. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -18391,23 +19068,29 @@ def begin_migrate_to_vm_scale_set( """ @distributed_trace - def begin_migrate_to_vm_scale_set( + def begin_reimage( self, resource_group_name: str, vm_name: str, - parameters: Optional[Union[_models.MigrateVMToVirtualMachineScaleSetInput, IO[bytes]]] = None, + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: - """Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. + """Reimages (upgrade the operating system) a virtual machine which don't have a ephemeral OS disk, + for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial + state. NOTE: The retaining of old OS disk depends on the value of deleteOption of OS disk. If + deleteOption is detach, the old OS disk will be preserved after reimage. If deleteOption is + delete, the old OS disk will be deleted after reimage. The deleteOption of the OS disk should + be updated accordingly before performing the reimage. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Migrate Virtual Machine operation. Is either a - MigrateVMToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateVMToVirtualMachineScaleSetInput - or IO[bytes] + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a + VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineReimageParameters or + IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -18422,7 +19105,7 @@ def begin_migrate_to_vm_scale_set( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._migrate_to_vm_scale_set_initial( + raw_result = self._reimage_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, @@ -18441,7 +19124,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -18455,13 +19140,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _run_command_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18470,29 +19149,17 @@ def _run_command_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RunCommandInput") - - _request = build_virtual_machines_run_command_request( + _request = build_virtual_machines_restart_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -18514,105 +19181,44 @@ def _run_command_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.RunCommandInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. + @distributed_trace + def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to restart a virtual machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - - @overload - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_run_command( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.RunCommandInput, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RunCommandResult]: - """Run command on the VM. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine. Required. - :type vm_name: str - :param parameters: Parameters supplied to the Run command operation. Is either a - RunCommandInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] - :return: An instance of LROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._run_command_initial( + raw_result = self._restart_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -18621,11 +19227,9 @@ def begin_run_command( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -18636,55 +19240,36 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.RunCommandResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.RunCommandResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class VirtualMachineImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get( - self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image. + def retrieve_boot_diagnostics_data( + self, + resource_group_name: str, + vm_name: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any + ) -> _models.RetrieveBootDiagnosticsDataResult: + """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs + with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated + with a default expiration duration of 120 minutes. Default value is None. + :paramtype sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18699,15 +19284,13 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_get_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, + _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, + sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, headers=_headers, params=_params, @@ -18725,47 +19308,20 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( + def _run_command_initial( self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, publisher, offer, - and SKU. - - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18774,166 +19330,203 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RunCommandInput") + + _request = build_virtual_machines_run_command_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_offers( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location and publisher. + @overload + def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.RunCommandInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + @overload + def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_list_offers_request( - location=location, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location. + def begin_run_command( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RunCommandResult]: + """Run command on the VM. - :param location: The name of a supported Azure region. Required. - :type location: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] + :return: An instance of LROPoller that returns either RunCommandResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._run_command_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_virtual_machine_images_list_publishers_request( - location=location, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RunCommandResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RunCommandResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - @distributed_trace - def list_skus( - self, location: str, publisher_name: str, offer: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. + def simulate_eviction( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> None: + """The operation to simulate the eviction of spot virtual machine. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18948,12 +19541,11 @@ def list_skus( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_skus_request( - location=location, - publisher_name=publisher_name, - offer=offer, + _request = build_virtual_machines_simulate_eviction_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -18968,29 +19560,14 @@ def list_skus( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_edge_zone(self, location: str, edge_zone: str, **kwargs: Any) -> _models.VmImagesInEdgeZoneListResult: - """Gets a list of all virtual machine image versions for the specified edge zone. + return cls(pipeline_response, None, {}) # type: ignore - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :return: VmImagesInEdgeZoneListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VmImagesInEdgeZoneListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19003,11 +19580,11 @@ def list_by_edge_zone(self, location: str, edge_zone: str, **kwargs: Any) -> _mo _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_by_edge_zone_request( - location=location, - edge_zone=edge_zone, + _request = build_virtual_machines_start_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -19015,63 +19592,110 @@ def list_by_edge_zone(self, location: str, edge_zone: str, **kwargs: Any) -> _mo ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def list_with_properties( - self, - location: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Union[str, _models.Expand], - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.VirtualMachineImage"]: - """list_with_properties. + def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: + """The operation to start a virtual machine. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. "Properties" Required. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.Expand - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: An iterator like instance of either VirtualMachineImage or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImagesWithPropertiesListResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + vm_name=vm_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_available_sizes( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachineSize"]: + """Lists all available virtual machine sizes to which the specified virtual machine can be + resized. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -19084,15 +19708,10 @@ def list_with_properties( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_images_list_with_properties_request( - location=location, - publisher_name=publisher_name, - offer=offer, - skus=skus, + _request = build_virtual_machines_list_available_sizes_request( + resource_group_name=resource_group_name, + vm_name=vm_name, subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -19117,7 +19736,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineImagesWithPropertiesListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -19141,14 +19760,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class VirtualMachineImagesEdgeZoneOperations: +class VirtualMachineSizesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. + :attr:`virtual_machine_sizes` attribute. """ models = _models @@ -19162,27 +19781,22 @@ def __init__(self, *args, **kwargs): self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def get( - self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineImage: - """Gets a virtual machine image in an edge zone. + def list(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineSize"]: + """This API is deprecated. Use `Resources Skus + `_. - :param location: The name of a supported Azure region. Required. + :param location: The name of Azure region. Required. :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImage + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19191,83 +19805,96 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + _request = build_virtual_machine_sizes_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_images_edge_zone_get_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - version=version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) + + +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list( - self, - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, - *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of all virtual machine image versions for the specified location, edge zone, - publisher, offer, and SKU. + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a subscription. - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :param skus: A valid image SKU. Required. - :type skus: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :keyword top: An integer value specifying the number of images to return that matches supplied - values. Default value is None. - :paramtype top: int - :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. - Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19276,120 +19903,79 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + _request = build_proximity_placement_groups_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_images_edge_zone_list_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, - subscription_id=self._config.subscription_id, - expand=expand, - top=top, - orderby=orderby, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def list_offers( - self, location: str, edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image offers for the specified location, edge zone and - publisher. + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ProximityPlacementGroup"]: + """Lists all proximity placement groups in a resource group. - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_publishers( - self, location: str, edge_zone: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19398,57 +19984,80 @@ def list_publishers( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + _request = build_proximity_placement_groups_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def list_skus( - self, location: str, edge_zone: str, publisher_name: str, offer: str, **kwargs: Any - ) -> List[_models.VirtualMachineImageResource]: - """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and - offer. + def get( + self, + resource_group_name: str, + proximity_placement_group_name: str, + *, + include_colocation_status: Optional[str] = None, + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Retrieves information about a proximity placement group . - :param location: The name of a supported Azure region. Required. - :type location: str - :param edge_zone: The name of the edge zone. Required. - :type edge_zone: str - :param publisher_name: A valid image publisher. Required. - :type publisher_name: str - :param offer: A valid image publisher offer. Required. - :type offer: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineImageResource] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :keyword include_colocation_status: includeColocationStatus=true enables fetching the + colocation status of all the resources in the proximity placement group. Default value is None. + :paramtype include_colocation_status: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19463,14 +20072,13 @@ def list_skus( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, + _request = build_proximity_placement_groups_get_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, + include_colocation_status=include_colocation_status, api_version=api_version, headers=_headers, params=_params, @@ -19488,50 +20096,89 @@ def list_skus( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: _models.ProximityPlacementGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. -class VirtualMachineExtensionImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. - """ - - models = _models + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @overload + def create_or_update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get( - self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. + def create_or_update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Create or update a proximity placement group. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :param version: Required. - :type version: str - :return: VirtualMachineExtensionImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is + either a ProximityPlacementGroup type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19542,19 +20189,29 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_get_request( - location=location, - publisher_name=publisher_name, - type=type, - version=version, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroup") + + _request = build_proximity_placement_groups_create_or_update_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -19567,29 +20224,94 @@ def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineExtensionImage", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: _models.ProximityPlacementGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def list_types( - self, location: str, publisher_name: str, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image types. + def update( + self, + resource_group_name: str, + proximity_placement_group_name: str, + parameters: Union[_models.ProximityPlacementGroupUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.ProximityPlacementGroup: + """Update a proximity placement group. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is + either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or + IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19600,17 +20322,29 @@ def list_types( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_list_types_request( - location=location, - publisher_name=publisher_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") + + _request = build_proximity_placement_groups_update_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -19627,7 +20361,7 @@ def list_types( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) + deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -19635,36 +20369,21 @@ def list_types( return deserialized # type: ignore @distributed_trace - def list_versions( - self, - location: str, - publisher_name: str, - type: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image versions. + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any + ) -> None: + """Delete a proximity placement group. - :param location: The name of a supported Azure region. Required. - :type location: str - :param publisher_name: Required. - :type publisher_name: str - :param type: Required. - :type type: str - :keyword filter: The filter to apply on the operation. Default value is None. - :paramtype filter: str - :keyword top: Default value is None. - :paramtype top: int - :keyword orderby: Default value is None. - :paramtype orderby: str - :return: list of VirtualMachineExtensionImage or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param proximity_placement_group_name: The name of the proximity placement group. Required. + :type proximity_placement_group_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -19676,16 +20395,12 @@ def list_versions( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_list_versions_request( - location=location, - publisher_name=publisher_name, - type=type, + _request = build_proximity_placement_groups_delete_request( + resource_group_name=resource_group_name, + proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, - filter=filter, - top=top, - orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -19703,22 +20418,18 @@ def list_versions( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore -class AvailabilitySetsOperations: +class RestorePointCollectionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`availability_sets` attribute. + :attr:`restore_point_collections` attribute. """ models = _models @@ -19731,79 +20442,24 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + @distributed_trace + def list_all(self, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections in the subscription. Use nextLink property in the + response to get the next page of restore point collections. Do this till nextLink is not null + to fetch all the restore point collections. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], - **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Create Availability Set operation. Is either a - AvailabilitySet type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19812,123 +20468,161 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySet") + _request = build_restore_point_collections_list_all_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - _request = build_availability_sets_create_or_update_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections in a resource group. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace - def update( - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + def prepare_request(next_link=None): + if not next_link: + + _request = build_restore_point_collections_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + *, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _models.RestorePointCollection: + """The operation to get the restore point collection. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :keyword expand: The expand expression to apply on the operation. If expand=restorePoints, + server will return all contained restore points in the restorePointCollection. "restorePoints" + Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19939,29 +20633,18 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - _request = build_availability_sets_update_request( + _request = build_restore_point_collections_get_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -19978,75 +20661,95 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> None: - """Delete an availability set. + @overload + def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_availability_sets_delete_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + @overload + def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. - if cls: - return cls(pipeline_response, None, {}) # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. + def create_or_update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollection, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to create or update the restore point collection. Please refer to + https://aka.ms/RestorePoints for more details. When updating a restore point collection, only + tags may be modified. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Create or Update restore point collection + operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20057,17 +20760,29 @@ def get(self, resource_group_name: str, availability_set_name: str, **kwargs: An } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - _request = build_availability_sets_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePointCollection") + + _request = build_restore_point_collections_create_or_update_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -20080,36 +20795,96 @@ def get(self, resource_group_name: str, availability_set_name: str, **kwargs: An response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. - - :keyword expand: The expand expression to apply to the operation. Allowed values are - 'virtualMachines/$ref'. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] + @overload + def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + @overload + def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.RestorePointCollection: + """The operation to update the restore point collection. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param parameters: Parameters supplied to the Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or + IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20118,75 +20893,55 @@ def list_by_subscription( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_availability_sets_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - def get_next(next_link=None): - _request = prepare_request(next_link) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _request = build_restore_point_collections_update_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return pipeline_response + response = pipeline_response.http_response - return ItemPaged(get_next, extract_data) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AvailabilitySet"]: - """Lists all availability sets in a resource group. + deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either AvailabilitySet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.AvailabilitySet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + return deserialized # type: ignore + def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20195,79 +20950,145 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Ava } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_availability_sets_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_restore_point_collections_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return pipeline_response + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list_available_sizes( - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSize"]: - """Lists all available virtual machine sizes that can be used to create a new virtual machine in - an existing availability set. + def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the restore point collection. This operation will also delete all the + contained restore points. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineSize] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SshPublicKeyResource"]: + """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response + to get the next page of SSH public keys. + + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20280,9 +21101,7 @@ def list_available_sizes( def prepare_request(next_link=None): if not next_link: - _request = build_availability_sets_list_available_sizes_request( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + _request = build_ssh_public_keys_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -20308,11 +21127,11 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -20331,86 +21150,100 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - @overload - def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.SshPublicKeyResource"]: + """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in + the response to get the next page of SSH public keys. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :type resource_group_name: str + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def start_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_ssh_public_keys_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], - **kwargs: Any - ) -> None: - """Start migration operation on an Availability Set to move its Virtual Machines to a Virtual - Machine Scale Set. This should be followed by a migrate operation on each Virtual Machine that - triggers a downtime on the Virtual Machine. + def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) -> _models.SshPublicKeyResource: + """Retrieves information about an SSH public key. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20421,29 +21254,17 @@ def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsisten } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") - - _request = build_availability_sets_start_migration_to_virtual_machine_scale_set_request( + _request = build_ssh_public_keys_get_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -20456,25 +21277,91 @@ def start_migration_to_virtual_machine_scale_set( # pylint: disable=inconsisten response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long - self, resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> None: - """Cancel the migration operation on an Availability Set. + def create( + self, + resource_group_name: str, + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyResource, IO[bytes]], + **kwargs: Any + ) -> _models.SshPublicKeyResource: + """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :return: None or the result of cls(response) - :rtype: None + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to create the SSH public key. Is either a + SshPublicKeyResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20485,17 +21372,29 @@ def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsiste } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - _request = build_availability_sets_cancel_migration_to_virtual_machine_scale_set_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SshPublicKeyResource") + + _request = build_ssh_public_keys_create_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -20508,90 +21407,92 @@ def cancel_migration_to_virtual_machine_scale_set( # pylint: disable=inconsiste response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + def update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.MigrateToVirtualMachineScaleSetInput, + ssh_public_key_name: str, + parameters: _models.SshPublicKeyUpdateResource, *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=name-too-long + def update( self, resource_group_name: str, - availability_set_name: str, + ssh_public_key_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsistent-return-statements,name-too-long + def update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.MigrateToVirtualMachineScaleSetInput, IO[bytes]], + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyUpdateResource, IO[bytes]], **kwargs: Any - ) -> None: - """Validates that the Virtual Machines in the Availability Set can be migrated to the provided - Virtual Machine Scale Set. + ) -> _models.SshPublicKeyResource: + """Updates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a MigrateToVirtualMachineScaleSetInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.MigrateToVirtualMachineScaleSetInput - or IO[bytes] - :return: None or the result of cls(response) - :rtype: None + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to update the SSH public key. Is either a + SshPublicKeyUpdateResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or + IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20607,7 +21508,7 @@ def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsis api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -20615,11 +21516,11 @@ def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsis if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "MigrateToVirtualMachineScaleSetInput") + _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") - _request = build_availability_sets_validate_migration_to_virtual_machine_scale_set_request( + _request = build_ssh_public_keys_update_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -20637,20 +21538,32 @@ def validate_migration_to_virtual_machine_scale_set( # pylint: disable=inconsis response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any + ) -> None: + """Delete an SSH public key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20659,276 +21572,117 @@ def _convert_to_virtual_machine_scale_set_initial( # pylint: disable=name-too-l } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "ConvertToVirtualMachineScaleSetInput") - else: - _json = None + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_availability_sets_convert_to_virtual_machine_scale_set_request( + _request = build_ssh_public_keys_delete_request( resource_group_name=resource_group_name, - availability_set_name=availability_set_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + def generate_key_pair( self, resource_group_name: str, - availability_set_name: str, - parameters: Optional[_models.ConvertToVirtualMachineScaleSetInput] = None, + ssh_public_key_name: str, + parameters: Optional[_models.SshGenerateKeyPairInputParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long + def generate_key_pair( self, resource_group_name: str, - availability_set_name: str, + ssh_public_key_name: str, parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. - Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_convert_to_virtual_machine_scale_set( # pylint: disable=name-too-long - self, - resource_group_name: str, - availability_set_name: str, - parameters: Optional[Union[_models.ConvertToVirtualMachineScaleSetInput, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Create a new Flexible Virtual Machine Scale Set and migrate all the Virtual Machines in the - Availability Set. This does not trigger a downtime on the Virtual Machines. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param availability_set_name: The name of the availability set. Required. - :type availability_set_name: str - :param parameters: Parameters supplied to the migrate operation on the availability set. Is - either a ConvertToVirtualMachineScaleSetInput type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ConvertToVirtualMachineScaleSetInput - or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._convert_to_virtual_machine_scale_set_initial( - resource_group_name=resource_group_name, - availability_set_name=availability_set_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - -class ProximityPlacementGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. - Required. + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Default value is None. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def generate_key_pair( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], + ssh_public_key_name: str, + parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Create or update a proximity placement group. + ) -> _models.SshPublicKeyGenerateKeyPairResult: + """Generates and returns a public/private key pair and populates the SSH public key resource with + the public key. The length of the key will be 3072 bits. This operation can only be performed + once per SSH public key resource. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is - either a ProximityPlacementGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :param ssh_public_key_name: The name of the SSH public key. Required. + :type ssh_public_key_name: str + :param parameters: Parameters supplied to generate the SSH public key. Is either a + SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or + IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20944,7 +21698,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -20952,11 +21706,14 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ProximityPlacementGroup") + if parameters is not None: + _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") + else: + _json = None - _request = build_proximity_placement_groups_create_or_update_request( + _request = build_ssh_public_keys_generate_key_pair_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -20974,91 +21731,149 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: _models.ProximityPlacementGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. - Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def update( - self, - resource_group_name: str, - proximity_placement_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_capacity_reservation_group( + self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any + ) -> Iterable["_models.CapacityReservation"]: + """Lists all of the capacity reservations in the specified capacity reservation group. Use the + nextLink property in the response to get the next page of capacity reservations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :return: An iterator like instance of either CapacityReservation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_capacity_reservations_list_by_capacity_reservation_group_request( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def update( + def get( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: Union[_models.ProximityPlacementGroupUpdate, IO[bytes]], + capacity_reservation_group_name: str, + capacity_reservation_name: str, + *, + expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Update a proximity placement group. + ) -> _models.CapacityReservation: + """The operation that retrieves information about the capacity reservation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is - either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroupUpdate or - IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a + snapshot of the runtime properties of the capacity reservation that is managed by the platform + and can change outside of control plane operations. "instanceView" Default value is None. + :paramtype expand: str or + ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -21069,29 +21884,19 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) - _request = build_proximity_placement_groups_update_request( + _request = build_capacity_reservations_get_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -21108,27 +21913,21 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> None: - """Delete a proximity placement group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _create_or_update_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21137,58 +21936,218 @@ def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_proximity_placement_groups_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservation") + + _request = build_capacity_reservations_create_or_update_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace - def get( + return deserialized # type: ignore + + @overload + def begin_create_or_update( self, resource_group_name: str, - proximity_placement_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservation, *, - include_colocation_status: Optional[str] = None, + content_type: str = "application/json", **kwargs: Any - ) -> _models.ProximityPlacementGroup: - """Retrieves information about a proximity placement group . + ) -> LROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param proximity_placement_group_name: The name of the proximity placement group. Required. - :type proximity_placement_group_name: str - :keyword include_colocation_status: includeColocationStatus=true enables fetching the - colocation status of all the resources in the proximity placement group. Default value is None. - :paramtype include_colocation_status: str - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to create or update a capacity reservation. Please note some properties can be + set only during capacity reservation creation. Please refer to + https://aka.ms/CapacityReservation for more details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Create capacity reservation. Is either a + CapacityReservation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21197,493 +22156,211 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_proximity_placement_groups_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CapacityReservationUpdate") + + _request = build_capacity_reservations_update_request( resource_group_name=resource_group_name, - proximity_placement_group_name=proximity_placement_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, - include_colocation_status=include_colocation_status, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. + @overload + def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. - :return: An iterator like instance of either ProximityPlacementGroup or the result of + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - _request = build_proximity_placement_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + @overload + def begin_update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.ProximityPlacementGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_proximity_placement_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroup, IO[bytes]], - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host - Groups please see [Dedicated Host Documentation] - (https://go.microsoft.com/fwlink/?linkid=2082596). - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") - - _request = build_dedicated_host_groups_create_or_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - host_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. - - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, - host_group_name: str, - parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. + ) -> LROPoller[_models.CapacityReservation]: + """The operation to update a capacity reservation. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either - a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :param parameters: Parameters supplied to the Update capacity reservation operation. Is either + a CapacityReservationUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] + :return: An instance of LROPoller that returns either CapacityReservation or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :raises ~azure.core.exceptions.HttpResponseError: + """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_dedicated_host_groups_update_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CapacityReservation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CapacityReservation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> None: - """Delete a dedicated host group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21696,11 +22373,12 @@ def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_host_groups_delete_request( + _request = build_capacity_reservations_delete_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -21708,103 +22386,142 @@ def delete( # pylint: disable=inconsistent-return-statements ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def get( + def begin_delete( self, resource_group_name: str, - host_group_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + capacity_reservation_group_name: str, + capacity_reservation_name: str, **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Retrieves information about a dedicated host group. + ) -> LROPoller[None]: + """The operation to delete a capacity reservation. This operation is allowed only when all the + associated resources are disassociated from the capacity reservation. Please refer to + https://aka.ms/CapacityReservation for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is - not supported for dedicated host group. Known values are: "instanceView", "userData", and - "resiliencyView". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup + :param capacity_reservation_group_name: The name of the capacity reservation group. Required. + :type capacity_reservation_group_name: str + :param capacity_reservation_name: The name of the capacity reservation. Required. + :type capacity_reservation_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + capacity_reservation_group_name=capacity_reservation_group_name, + capacity_reservation_name=capacity_reservation_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _request = build_dedicated_host_groups_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + models = _models - return deserialized # type: ignore + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: - """Lists all of the dedicated host groups in the specified resource group. Use the nextLink - property in the response to get the next page of dedicated host groups. + def list_by_host_group( + self, resource_group_name: str, host_group_name: str, **kwargs: Any + ) -> Iterable["_models.DedicatedHost"]: + """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink + property in the response to get the next page of dedicated hosts. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :return: An iterator like instance of either DedicatedHost or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -21817,8 +22534,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - _request = build_dedicated_host_groups_list_by_resource_group_request( + _request = build_dedicated_hosts_list_by_host_group_request( resource_group_name=resource_group_name, + host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -21844,7 +22562,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) + deserialized = self._deserialize("DedicatedHostListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -21868,20 +22586,33 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: - """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the - response to get the next page of dedicated host groups. + def get( + self, + resource_group_name: str, + host_group_name: str, + host_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.DedicatedHost: + """Retrieves information about a dedicated host. - :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHostGroup] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the list of instance views of the dedicated host. 'UserData' is not supported for dedicated + host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21890,78 +22621,41 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DedicatedHost } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_host_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - return pipeline_response + _request = build_dedicated_hosts_get_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return ItemPaged(get_next, extract_data) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response -class DedicatedHostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`dedicated_hosts` attribute. - """ + deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - models = _models + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + return deserialized # type: ignore def _create_or_update_initial( self, @@ -22024,10 +22718,15 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -22044,11 +22743,12 @@ def begin_create_or_update( ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost @@ -22074,11 +22774,12 @@ def begin_create_or_update( ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: IO[bytes] @@ -22102,11 +22803,12 @@ def begin_create_or_update( ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost type or a IO[bytes] type. Required. @@ -22148,7 +22850,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -22225,10 +22929,14 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -22245,11 +22953,12 @@ def begin_update( ) -> LROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHostUpdate @@ -22275,11 +22984,12 @@ def begin_update( ) -> LROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: IO[bytes] @@ -22303,11 +23013,12 @@ def begin_update( ) -> LROPoller[_models.DedicatedHost]: """Update a dedicated host . - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :param host_name: The name of the dedicated host . Required. + :param host_name: The name of the dedicated host. Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a DedicatedHostUpdate type or a IO[bytes] type. Required. @@ -22343,13 +23054,20 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -22409,10 +23127,15 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -22422,7 +23145,8 @@ def begin_delete( ) -> LROPoller[None]: """Delete a dedicated host. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str @@ -22454,116 +23178,51 @@ def begin_delete( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - host_group_name: str, - host_name: str, - *, - expand: Optional[Union[str, _models.InstanceViewTypes]] = None, - **kwargs: Any - ) -> _models.DedicatedHost: - """Retrieves information about a dedicated host. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the dedicated host. 'UserData' is not supported for dedicated - host. Known values are: "instanceView", "userData", and "resiliencyView". Default value is - None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.DedicatedHost - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) - - _request = build_dedicated_hosts_get_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_by_host_group( - self, resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHost"]: - """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink - property in the response to get the next page of dedicated hosts. + def list_available_sizes( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> Iterable[str]: + """Lists all available dedicated host sizes to which the specified dedicated host can be resized. + NOTE: The dedicated host sizes provided can be used to only scale up the existing dedicated + host. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str - :return: An iterator like instance of either DedicatedHost or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.DedicatedHost] + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An iterator like instance of either str or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[str] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -22576,9 +23235,10 @@ def list_by_host_group( def prepare_request(next_link=None): if not next_link: - _request = build_dedicated_hosts_list_by_host_group_request( + _request = build_dedicated_hosts_list_available_sizes_request( resource_group_name=resource_group_name, host_group_name=host_group_name, + host_name=host_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -22604,7 +23264,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostListResult", pipeline_response) + deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -22627,6 +23287,125 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + def _redeploy_initial( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_dedicated_hosts_redeploy_request( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_redeploy( + self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Redeploy the dedicated host. The operation will complete successfully once the dedicated host + has migrated to a new node and is running. To determine the health of VMs deployed on the + dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please + refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more + details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param host_group_name: The name of the dedicated host group. Required. + :type host_group_name: str + :param host_name: The name of the dedicated host. Required. + :type host_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._redeploy_initial( + resource_group_name=resource_group_name, + host_group_name=host_group_name, + host_name=host_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def _restart_initial( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> Iterator[bytes]: @@ -22671,10 +23450,14 @@ def _restart_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -22687,7 +23470,8 @@ def begin_restart( after the restart check the Resource Health Center in the Azure Portal. Please refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str @@ -22724,7 +23508,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -22738,8 +23524,104 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _redeploy_initial( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + *, + expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + **kwargs: Any + ) -> _models.RestorePoint: + """The operation to get the restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves + information about the run-time state of a restore point. "instanceView" Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_restore_points_get_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -22749,18 +23631,30 @@ def _redeploy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_hosts_redeploy_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePoint") + + _request = build_restore_points_create_request( resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -22774,7 +23668,7 @@ def _redeploy_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -22784,6 +23678,7 @@ def _redeploy_initial( response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -22792,192 +23687,155 @@ def _redeploy_initial( return deserialized # type: ignore - @distributed_trace - def begin_redeploy( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Redeploy the dedicated host. The operation will complete successfully once the dedicated host - has migrated to a new node and is running. To determine the health of VMs deployed on the - dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please - refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more - details. + @overload + def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: _models.RestorePoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._redeploy_initial( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def list_available_sizes( - self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any - ) -> Iterable[str]: - """Lists all available dedicated host sizes to which the specified dedicated host can be resized. - NOTE: The dedicated host sizes provided can be used to only scale up the existing dedicated - host. + @overload + def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param host_group_name: The name of the dedicated host group. Required. - :type host_group_name: str - :param host_name: The name of the dedicated host. Required. - :type host_name: str - :return: An iterator like instance of either str or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[str] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_dedicated_hosts_list_available_sizes_request( - resource_group_name=resource_group_name, - host_group_name=host_group_name, - host_name=host_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHostSizeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response - to get the next page of SSH public keys. + def begin_create( + self, + resource_group_name: str, + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """The operation to create the restore point. Updating properties of an existing restore point is + not allowed. - :return: An iterator like instance of either SshPublicKeyResource or the result of + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :param parameters: Parameters supplied to the Create restore point operation. Is either a + RestorePoint type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] + :return: An instance of LROPoller that returns either RestorePoint or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RestorePoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -22986,213 +23844,135 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SshPublicKeyR } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_ssh_public_keys_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_restore_points_delete_request( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return pipeline_response + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeyResource"]: - """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in - the response to get the next page of SSH public keys. + def begin_delete( + self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the restore point. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource] + :param restore_point_collection_name: The name of the restore point collection. Required. + :type restore_point_collection_name: str + :param restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_ssh_public_keys_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + restore_point_collection_name=restore_point_collection_name, + restore_point_name=restore_point_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ +class VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + models = _models - @distributed_trace - def create( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to create the SSH public key. Is either a - SshPublicKeyResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _start_extension_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -23201,194 +23981,224 @@ def create( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyResource") + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_create_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyUpdateResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + @distributed_trace + def begin_start_extension_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to + the latest available extension version. Instances which are already running the latest + extension versions are not affected. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_extension_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace - def update( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyUpdateResource, IO[bytes]], - **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Updates a new SSH public key resource. + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to update the SSH public key. Is either a - SshPublicKeyUpdateResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _start_os_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_ssh_public_keys_update_request( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> None: - """Delete an SSH public key. + def begin_start_os_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Starts a rolling upgrade to move all virtual machine scale set instances to the latest + available Platform Image OS version. Instances which are already running the latest available + OS version are not affected. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: None or the result of cls(response) - :rtype: None + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_os_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -23401,11 +24211,11 @@ def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_delete_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -23413,30 +24223,102 @@ def delete( # pylint: disable=inconsistent-return-statements ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) -> _models.SshPublicKeyResource: - """Retrieves information about an SSH public key. + def begin_cancel(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> LROPoller[None]: + """Cancels the current virtual machine scale set rolling upgrade. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyResource + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cancel_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_latest( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> _models.RollingUpgradeStatusInfo: + """Gets the status of the latest virtual machine scale set rolling upgrade. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: RollingUpgradeStatusInfo or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RollingUpgradeStatusInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -23451,11 +24333,11 @@ def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_get_request( + _request = build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -23474,91 +24356,142 @@ def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) + deserialized = self._deserialize("RollingUpgradeStatusInfo", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachineScaleSetExtension"]: + """Gets a list of all extensions in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_machine_scale_set_extensions_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - return deserialized # type: ignore + def get_next(next_link=None): + _request = prepare_request(next_link) - @overload - def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[_models.SshGenerateKeyPairInputParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - def generate_key_pair( - self, - resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + return pipeline_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Default value is None. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def generate_key_pair( + def get( self, resource_group_name: str, - ssh_public_key_name: str, - parameters: Optional[Union[_models.SshGenerateKeyPairInputParameters, IO[bytes]]] = None, + vm_scale_set_name: str, + vmss_extension_name: str, + *, + expand: Optional[str] = None, **kwargs: Any - ) -> _models.SshPublicKeyGenerateKeyPairResult: - """Generates and returns a public/private key pair and populates the SSH public key resource with - the public key. The length of the key will be 3072 bits. This operation can only be performed - once per SSH public key resource. + ) -> _models.VirtualMachineScaleSetExtension: + """The operation to get the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param ssh_public_key_name: The name of the SSH public key. Required. - :type ssh_public_key_name: str - :param parameters: Parameters supplied to generate the SSH public key. Is either a - SshGenerateKeyPairInputParameters type or a IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.SshPublicKeyGenerateKeyPairResult + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -23569,32 +24502,19 @@ def generate_key_pair( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - if parameters is not None: - _json = self._serialize.body(parameters, "SshGenerateKeyPairInputParameters") - else: - _json = None + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_generate_key_pair_request( + _request = build_virtual_machine_scale_set_extensions_get_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -23611,36 +24531,20 @@ def generate_key_pair( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class ImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`images` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - def _create_or_update_initial( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -23660,14 +24564,15 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "Image") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") - _request = build_images_create_or_update_request( + _request = build_virtual_machine_scale_set_extensions_create_or_update_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -23694,10 +24599,15 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -23705,25 +24615,33 @@ def _create_or_update_initial( def begin_create_or_update( self, resource_group_name: str, - image_name: str, - parameters: _models.Image, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetExtension, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update an image. + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -23731,43 +24649,61 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - image_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update an image. + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def begin_create_or_update( - self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Image]: - """Create or update an image. + self, + resource_group_name: str, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to create or update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.Image or IO[bytes] - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Create VM scale set Extension + operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -23775,15 +24711,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -23795,33 +24732,36 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Image].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Image]( + return LROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _update_initial( self, resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -23842,14 +24782,15 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "ImageUpdate") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") - _request = build_images_update_request( + _request = build_virtual_machine_scale_set_extensions_update_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -23876,10 +24817,15 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -23887,25 +24833,33 @@ def _update_initial( def begin_update( self, resource_group_name: str, - image_name: str, - parameters: _models.ImageUpdate, + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update an image. + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -23913,25 +24867,32 @@ def begin_update( def begin_update( self, resource_group_name: str, - image_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update an image. + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Required. - :type parameters: IO[bytes] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -23939,21 +24900,29 @@ def begin_update( def begin_update( self, resource_group_name: str, - image_name: str, - parameters: Union[_models.ImageUpdate, IO[bytes]], + vm_scale_set_name: str, + vmss_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Image]: - """Update an image. + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: + """The operation to update an extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ImageUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Image or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.Image] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str + :param extension_parameters: Parameters supplied to the Update VM scale set Extension + operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. + Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -23961,15 +24930,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, - image_name=image_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -23981,29 +24951,33 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Image", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.Image].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Image]( + return LROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> Iterator[bytes]: + def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24018,9 +24992,10 @@ def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_images_delete_request( + _request = build_virtual_machine_scale_set_extensions_delete_request( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -24044,21 +25019,31 @@ def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: A map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an Image. + def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param vmss_extension_name: The name of the VM scale set extension. Required. + :type vmss_extension_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -24074,7 +25059,8 @@ def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - image_name=image_name, + vm_scale_set_name=vm_scale_set_name, + vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -24082,102 +25068,89 @@ def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) **kwargs ) raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Image: - """Gets an image. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param image_name: The name of the image. Required. - :type image_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: Image or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.Image - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.Image] = kwargs.pop("cls", None) - - _request = build_images_get_request( - resource_group_name=resource_group_name, - image_name=image_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + kwargs.pop("error_map", None) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - response = pipeline_response.http_response + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Image", pipeline_response.http_response) +class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. + """ - return deserialized # type: ignore + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Image"]: - """Gets the list of images under a resource group. Use nextLink property in the response to get - the next page of Images. Do this till nextLink is null to fetch all the Images. + def list( + self, + resource_group_name: str, + virtual_machine_scale_set_name: str, + *, + filter: Optional[str] = None, + select: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineScaleSetVM"]: + """Gets a list of all virtual machines in a VM scale sets. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :return: An iterator like instance of either Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] + :param virtual_machine_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type virtual_machine_scale_set_name: str + :keyword filter: The filter to apply to the operation. Allowed values are + 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied + eq true', 'properties/latestModelApplied eq false'. Default value is None. + :paramtype filter: str + :keyword select: The list parameters. Allowed values are 'instanceView', + 'instanceView/statuses'. Default value is None. + :paramtype select: str + :keyword expand: The expand expression to apply to the operation. Allowed values are + 'instanceView'. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -24190,9 +25163,13 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - _request = build_images_list_by_resource_group_request( + _request = build_virtual_machine_scale_set_vms_list_request( resource_group_name=resource_group_name, + virtual_machine_scale_set_name=virtual_machine_scale_set_name, subscription_id=self._config.subscription_id, + filter=filter, + select=select, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -24217,7 +25194,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -24241,20 +25218,33 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Image"]: - """Gets the list of Images in the subscription. Use nextLink property in the response to get the - next page of Images. Do this till nextLink is null to fetch all the Images. + def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVM: + """Gets a virtual machine from a VM scale set. - :return: An iterator like instance of either Image or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.Image] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve + the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual + machine. Known values are: "instanceView", "userData", and "resiliencyView". Default value is + None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24263,160 +25253,53 @@ def list(self, **kwargs: Any) -> Iterable["_models.Image"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_images_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ImageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class RestorePointCollectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`restore_point_collections` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) - models = _models + _request = build_virtual_machine_scale_set_vms_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - @overload - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. + response = pipeline_response.http_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @overload - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. + deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - @distributed_trace - def create_or_update( + return deserialized # type: ignore + + def _update_initial( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to create or update the restore point collection. Please refer to - https://aka.ms/RestorePoints for more details. When updating a restore point collection, only - tags may be modified. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Create or Update restore point collection - operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24430,7 +25313,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -24438,12 +25321,15 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "RestorePointCollection") + _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") - _request = build_restore_point_collections_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_update_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, @@ -24453,156 +25339,218 @@ def create_or_update( ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def update( + def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: _models.RestorePointCollectionUpdate, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.VirtualMachineScaleSetVM, *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. :type parameters: IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to update the restore point collection. + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: + """Updates a virtual machine of a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param parameters: Parameters supplied to the Update restore point collection operation. Is - either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. + Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM or IO[bytes] + :keyword if_match: The ETag of the transformation. Omit this value to always overwrite the + current resource. Specify the last-seen ETag value to prevent accidentally overwriting + concurrent changes. Default value is None. + :paramtype if_match: str + :keyword if_none_match: Set to '*' to allow a new record set to be created, but to prevent + updating an existing record set. Other values will result in error from server as they are not + supported. Default value is None. + :paramtype if_none_match: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - - _request = build_restore_point_collections_update_request( - resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + parameters=parameters, + if_match=if_match, + if_none_match=if_none_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - return deserialized # type: ignore + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineScaleSetVM]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -24618,10 +25566,12 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_point_collections_delete_request( + _request = build_virtual_machine_scale_set_vms_delete_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, @@ -24644,24 +25594,40 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + force_deletion: Optional[bool] = None, + **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the restore point collection. This operation will also delete all the - contained restore points. + """Deletes a virtual machine from a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the Restore Point Collection. Required. - :type restore_point_collection_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword force_deletion: Optional parameter to force delete a virtual machine from a VM scale + set. (Feature in Preview). Default value is None. + :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -24677,7 +25643,9 @@ def begin_delete( if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -24692,7 +25660,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -24706,30 +25676,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - *, - expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePointCollection: - """The operation to get the restore point collection. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :keyword expand: The expand expression to apply on the operation. If expand=restorePoints, - server will return all contained restore points in the restorePointCollection. "restorePoints" - Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _approve_rolling_upgrade_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24742,221 +25691,112 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_point_collections_get_request( + _request = build_virtual_machine_scale_set_vms_approve_rolling_upgrade_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: - """Gets the list of restore point collections in a resource group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_all(self, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: - """Gets the list of restore point collections in the subscription. Use nextLink property in the - response to get the next page of restore point collections. Do this till nextLink is not null - to fetch all the restore point collections. - - :return: An iterator like instance of either RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RestorePointCollection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_restore_point_collections_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore + @distributed_trace + def begin_approve_rolling_upgrade( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Approve upgrade on deferred rolling upgrade for OS disk on a VM scale set instance. -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._approve_rolling_upgrade_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_initial( + def _attach_detach_data_disks_initial( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -24980,12 +25820,12 @@ def _create_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "RestorePoint") + _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") - _request = build_restore_points_create_request( + _request = build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -25004,7 +25844,7 @@ def _create_initial( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -25012,99 +25852,108 @@ def _create_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_create( + def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: _models.RestorePoint, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.AttachDetachDataDisksRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of + :return: An instance of LROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create( + def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Required. + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of + :return: An instance of LROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create( + def begin_attach_detach_data_disks( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - parameters: Union[_models.RestorePoint, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """The operation to create the restore point. Updating properties of an existing restore point is - not allowed. + ) -> LROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :param parameters: Parameters supplied to the Create restore point operation. Is either a - RestorePoint type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint or IO[bytes] - :return: An instance of LROPoller that returns either RestorePoint or the result of + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the attach and detach data disks operation on a + Virtual Machine Scale Sets VM. Is either a AttachDetachDataDisksRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.AttachDetachDataDisksRequest or + IO[bytes] + :return: An instance of LROPoller that returns either StorageProfile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RestorePoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -25112,15 +25961,15 @@ def begin_create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.StorageProfile] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( + raw_result = self._attach_detach_data_disks_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, @@ -25133,30 +25982,32 @@ def begin_create( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.RestorePoint].from_continuation_token( + return LROPoller[_models.StorageProfile].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.RestorePoint]( + return LROPoller[_models.StorageProfile]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + def _deallocate_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -25172,10 +26023,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_points_delete_request( + _request = build_virtual_machine_scale_set_vms_deallocate_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -25191,7 +26042,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -25199,25 +26050,33 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete( - self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + def begin_deallocate( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the restore point. + """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and + releases the compute resources it uses. You are not billed for the compute resources of this + virtual machine once it is deallocated. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param restore_point_collection_name: The name of the Restore Point Collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -25231,10 +26090,10 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._deallocate_initial( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -25249,7 +26108,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -25264,28 +26125,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, - *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, - **kwargs: Any - ) -> _models.RestorePoint: - """The operation to get the restore point. + def get_instance_view( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> _models.VirtualMachineScaleSetVMInstanceView: + """Gets the status of a virtual machine from a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param restore_point_collection_name: The name of the restore point collection. Required. - :type restore_point_collection_name: str - :param restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves - information about the run-time state of a restore point. "instanceView" Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_11_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RestorePoint + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: VirtualMachineScaleSetVMInstanceView or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -25300,14 +26153,13 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) - _request = build_restore_points_get_request( + _request = build_virtual_machine_scale_set_vms_get_instance_view_request( resource_group_name=resource_group_name, - restore_point_collection_name=restore_point_collection_name, - restore_point_name=restore_point_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -25325,113 +26177,16 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class CapacityReservationGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroup, IO[bytes]], - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to create or update a capacity reservation group. When updating a capacity - reservation group, only tags and sharing profile may be modified. Please refer to - https://aka.ms/CapacityReservation for more details. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a - CapacityReservationGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _perform_maintenance_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25440,131 +26195,120 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationGroup") + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. + @distributed_trace + def begin_perform_maintenance( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Performs maintenance on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._perform_maintenance_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace - def update( + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _power_off_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + *, + skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation to update a capacity reservation group. When updating a capacity reservation - group, only tags and sharing profile may be modified. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param parameters: Parameters supplied to the Update capacity reservation Group operation. Is - either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25573,69 +26317,128 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_update_request( + _request = build_virtual_machine_scale_set_vms_power_off_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + skip_shutdown=skip_shutdown, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> None: - """The operation to delete a capacity reservation group. This operation is allowed only if all the - associated resources are disassociated from the reservation group and all capacity reservations - under the reservation group have also been deleted. Please refer to - https://aka.ms/CapacityReservation for more details. + def begin_power_off( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached + and you are getting charged for the resources. Instead, use deallocate to release resources and + avoid charges. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: None or the result of cls(response) - :rtype: None + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this + flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this + flag is false if not specified. Default value is None. + :paramtype skip_shutdown: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._power_off_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + skip_shutdown=skip_shutdown, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _redeploy_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25648,11 +26451,12 @@ def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_delete_request( + _request = build_virtual_machine_scale_set_vms_redeploy_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -25660,46 +26464,105 @@ def delete( # pylint: disable=inconsistent-return-statements ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_redeploy( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and + powers it back on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._redeploy_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace - def get( + def _reimage_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - *, - expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, **kwargs: Any - ) -> _models.CapacityReservationGroup: - """The operation that retrieves information about a capacity reservation group. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve - the list of instance views of the capacity reservations under the capacity reservation group - which is a snapshot of the runtime properties of a capacity reservation that is managed by the - platform and can change outside of control plane operations. "instanceView" Default value is - None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25708,172 +26571,207 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_vm_reimage_input + else: + if vm_scale_set_vm_reimage_input is not None: + _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") + else: + _json = None + + _request = build_virtual_machine_scale_set_vms_reimage_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_resource_group( + @overload + def begin_reimage( self, resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + content_type: str = "application/json", **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroup"]: - """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink - property in the response to get the next page of capacity reservation groups. + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) - specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are - associated to capacity reservation group in the response. Known values are: - "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Default value is None. + :type vm_scale_set_vm_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_capacity_reservation_groups_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response + @overload + def begin_reimage( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - return ItemPaged(get_next, extract_data) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Default value is None. + :type vm_scale_set_vm_reimage_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_by_subscription( + def begin_reimage( self, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroup"]: - """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in - the response to get the next page of capacity reservation groups. + ) -> LROPoller[None]: + """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. - :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) - specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are - associated to capacity reservation group in the response. Known values are: - "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.ExpandTypesForGetCapacityReservationGroups - :keyword resource_ids_only: The query option to fetch Capacity Reservation Group Resource Ids. - :code:`
` 'CreatedInSubscription' enables fetching Resource Ids for all capacity reservation - group resources created in the subscription. :code:`
` 'SharedWithSubscription' enables - fetching Resource Ids for all capacity reservation group resources shared with the - subscription. :code:`
` 'All' enables fetching Resource Ids for all capacity reservation - group resources shared with the subscription and created in the subscription. Known values are: - "CreatedInSubscription", "SharedWithSubscription", and "All". Default value is None. - :paramtype resource_ids_only: str or - ~azure.mgmt.compute.v2024_11_01.models.ResourceIdOptionsForGetCapacityReservationGroups - :return: An iterator like instance of either CapacityReservationGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservationGroup] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. + Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value + is None. + :type vm_scale_set_vm_reimage_input: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reimage_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def _reimage_all_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25882,88 +26780,114 @@ def list_by_subscription( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_capacity_reservation_groups_list_by_subscription_request( - subscription_id=self._config.subscription_id, - expand=expand, - resource_ids_only=resource_ids_only, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + _request = build_virtual_machine_scale_set_vms_reimage_all_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return pipeline_response + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + @distributed_trace + def begin_reimage_all( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. + This operation is only supported for managed disks. -class CapacityReservationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reimage_all_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_or_update_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservation, IO[bytes]], - **kwargs: Any + def _restart_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -25973,30 +26897,18 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CapacityReservation") - - _request = build_capacity_reservations_create_or_update_request( + _request = build_virtual_machine_scale_set_vms_restart_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -26010,132 +26922,57 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - @overload - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservation, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to create or update a capacity reservation. Please note some properties can be - set only during capacity reservation creation. Please refer to - https://aka.ms/CapacityReservation for more details. + def begin_restart( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Restarts a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Create capacity reservation. Is either a - CapacityReservation type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation or IO[bytes] - :return: An instance of LROPoller that returns either CapacityReservation or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._restart_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, - parameters=parameters, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -26144,35 +26981,105 @@ def begin_create_or_update( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.CapacityReservation].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CapacityReservation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def retrieve_boot_diagnostics_data( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + sas_uri_expiration_time_in_minutes: Optional[int] = None, + **kwargs: Any + ) -> _models.RetrieveBootDiagnosticsDataResult: + """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale + set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs + with a value between 1 to 1440 minutes. **Note:** If not specified, SAS URIs will be generated + with a default expiration duration of 120 minutes. Default value is None. + :paramtype sas_uri_expiration_time_in_minutes: int + :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.RetrieveBootDiagnosticsDataResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, + api_version=api_version, + headers=_headers, + params=_params, ) + _request.url = self._client.format_url(_request.url) - def _update_initial( + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _run_command_initial( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -26196,12 +27103,12 @@ def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "CapacityReservationUpdate") + _json = self._serialize.body(parameters, "RunCommandInput") - _request = build_capacity_reservations_update_request( + _request = build_virtual_machine_scale_set_vms_run_command_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -26228,99 +27135,104 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_update( + def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: _models.CapacityReservationUpdate, + vm_scale_set_name: str, + instance_id: str, + parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of + :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Required. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either CapacityReservation or the result of + :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_run_command( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.CapacityReservation]: - """The operation to update a capacity reservation. + ) -> LROPoller[_models.RunCommandResult]: + """Run command on a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :param parameters: Parameters supplied to the Update capacity reservation operation. Is either - a CapacityReservationUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationUpdate or IO[bytes] - :return: An instance of LROPoller that returns either CapacityReservation or the result of + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param parameters: Parameters supplied to the Run command operation. Is either a + RunCommandInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RunCommandInput or IO[bytes] + :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -26328,15 +27240,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._run_command_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, @@ -26349,34 +27261,88 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.CapacityReservation].from_continuation_token( + return LROPoller[_models.RunCommandResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.CapacityReservation]( + return LROPoller[_models.RunCommandResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any + @distributed_trace + def simulate_eviction( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + ) -> None: + """The operation to simulate the eviction of spot virtual machine in a VM scale set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _start_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -26392,10 +27358,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservations_delete_request( + _request = build_virtual_machine_scale_set_vms_start_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -26411,7 +27377,7 @@ def _delete_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -26419,31 +27385,31 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def begin_delete( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, - **kwargs: Any + def begin_start( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: - """The operation to delete a capacity reservation. This operation is allowed only when all the - associated resources are disassociated from the capacity reservation. Please refer to - https://aka.ms/CapacityReservation for more details. + """Starts a virtual machine in a VM scale set. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -26457,10 +27423,10 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._start_initial( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -26470,50 +27436,145 @@ def begin_delete( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: + """The operation to get all extensions of an instance in Virtual Machine Scaleset. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionsListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_set_vm_extensions_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace def get( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, *, - expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, + expand: Optional[str] = None, **kwargs: Any - ) -> _models.CapacityReservation: - """The operation that retrieves information about the capacity reservation. + ) -> _models.VirtualMachineScaleSetVMExtension: + """The operation to get the VMSS VM extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :param capacity_reservation_name: The name of the capacity reservation. Required. - :type capacity_reservation_name: str - :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a - snapshot of the runtime properties of the capacity reservation that is managed by the platform - and can change outside of control plane operations. "instanceView" Default value is None. - :paramtype expand: str or - ~azure.mgmt.compute.v2024_11_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.CapacityReservation + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineScaleSetVMExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -26528,12 +27589,13 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) - _request = build_capacity_reservations_get_request( + _request = build_virtual_machine_scale_set_vm_extensions_get_request( resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - capacity_reservation_name=capacity_reservation_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -26553,35 +27615,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_by_capacity_reservation_group( - self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> Iterable["_models.CapacityReservation"]: - """Lists all of the capacity reservations in the specified capacity reservation group. Use the - nextLink property in the response to get the next page of capacity reservations. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param capacity_reservation_group_name: The name of the capacity reservation group. Required. - :type capacity_reservation_group_name: str - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) - + def _create_or_update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -26590,83 +27639,227 @@ def list_by_capacity_reservation_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _request = build_capacity_reservations_list_by_capacity_reservation_group_request( - resource_group_name=resource_group_name, - capacity_reservation_group_name=capacity_reservation_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + _request = build_virtual_machine_scale_set_vm_extensions_create_or_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - def get_next(next_link=None): - _request = prepare_request(next_link) + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - return ItemPaged(get_next, extract_data) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetVMExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to create or update the VMSS VM extension. -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - models = _models + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualMachineScaleSetVMExtension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _export_request_rate_by_interval_initial( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any + def _update_initial( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -26686,13 +27879,16 @@ def _export_request_rate_by_interval_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(parameters, "RequestRateByIntervalInput") + _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") - _request = build_log_analytics_export_request_rate_by_interval_request( - location=location, + _request = build_virtual_machine_scale_set_vm_extensions_update_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -26711,7 +27907,7 @@ def _export_request_rate_by_interval_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -26719,79 +27915,120 @@ def _export_request_rate_by_interval_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @overload - def begin_export_request_rate_by_interval( + def begin_update( self, - location: str, - parameters: _models.RequestRateByIntervalInput, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_export_request_rate_by_interval( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type parameters: IO[bytes] + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_export_request_rate_by_interval( - self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show Api requests made by this subscription in the given time window to show - throttling activities. + def begin_update( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: + """The operation to update the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is - either a RequestRateByIntervalInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.RequestRateByIntervalInput or - IO[bytes] - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. + Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the + result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -26799,14 +28036,17 @@ def begin_export_request_rate_by_interval( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._export_request_rate_by_interval_initial( - location=location, - parameters=parameters, + raw_result = self._update_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -26818,32 +28058,37 @@ def begin_export_request_rate_by_interval( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.LogAnalyticsOperationResult]( + return LROPoller[_models.VirtualMachineScaleSetVMExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _export_throttled_requests_initial( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any + def _delete_initial( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -26853,28 +28098,19 @@ def _export_throttled_requests_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ThrottledRequestsInput") - - _request = build_log_analytics_export_throttled_requests_request( - location=location, + _request = build_virtual_machine_scale_set_vm_extensions_delete_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -26888,7 +28124,7 @@ def _export_throttled_requests_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -26896,93 +28132,52 @@ def _export_throttled_requests_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_export_throttled_requests( - self, - location: str, - parameters: _models.ThrottledRequestsInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_export_throttled_requests( - self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. - - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_export_throttled_requests( - self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.LogAnalyticsOperationResult]: - """Export logs that show total throttled Api requests for this subscription in the given time - window. + def begin_delete( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The operation to delete the VMSS VM extension. - :param location: The location upon which virtual-machine-sizes is queried. Required. - :type location: str - :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Is either - a ThrottledRequestsInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_11_01.models.ThrottledRequestsInput or IO[bytes] - :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.LogAnalyticsOperationResult] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VM scale set. Required. + :type vm_scale_set_name: str + :param instance_id: The instance ID of the virtual machine. Required. + :type instance_id: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._export_throttled_requests_initial( - location=location, - parameters=parameters, + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + vm_extension_name=vm_extension_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -26991,40 +28186,36 @@ def begin_export_throttled_requests( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.LogAnalyticsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore -class VirtualMachineRunCommandsOperations: +class VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models @@ -27038,22 +28229,37 @@ def __init__(self, *args, **kwargs): self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace - def list(self, location: str, **kwargs: Any) -> Iterable["_models.RunCommandDocumentBase"]: - """Lists all available run commands for a subscription in a location. + def list( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineRunCommand"]: + """The operation to get all run commands of an instance in Virtual Machine Scaleset. - :param location: The location upon which run commands is queried. Required. - :type location: str - :return: An iterator like instance of either RunCommandDocumentBase or the result of + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: An iterator like instance of either VirtualMachineRunCommand or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.RunCommandDocumentBase] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -27066,9 +28272,12 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.RunCommandDocu def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_run_commands_list_request( - location=location, + _request = build_virtual_machine_scale_set_vm_run_commands_list_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -27093,7 +28302,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("RunCommandListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -27117,15 +28326,31 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: - """Gets specific run command for a subscription in a location. + def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + run_command_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineRunCommand: + """The operation to get the VMSS VM run command. - :param location: The location upon which run commands is queried. Required. - :type location: str - :param command_id: The command id. Required. - :type command_id: str - :return: RunCommandDocument or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.RunCommandDocument + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. + :type run_command_name: str + :keyword expand: The expand expression to apply on the operation. Default value is None. + :paramtype expand: str + :return: VirtualMachineRunCommand or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -27140,12 +28365,15 @@ def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunComma _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_get_request( - location=location, - command_id=command_id, + _request = build_virtual_machine_scale_set_vm_run_commands_get_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, + run_command_name=run_command_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -27163,7 +28391,7 @@ def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunComma map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RunCommandDocument", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -27173,7 +28401,8 @@ def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunComma def _create_or_update_initial( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any @@ -27201,9 +28430,10 @@ def _create_or_update_initial( else: _json = self._serialize.body(run_command, "VirtualMachineRunCommand") - _request = build_virtual_machine_run_commands_create_or_update_request( + _request = build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -27231,10 +28461,15 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -27242,21 +28477,24 @@ def _create_or_update_initial( def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommand, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. @@ -27275,27 +28513,30 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) @@ -27308,19 +28549,22 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the run command. + """The operation to create or update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be created or - updated. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommand type or a IO[bytes] type. Required. @@ -27343,7 +28587,8 @@ def begin_create_or_update( if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, @@ -27363,7 +28608,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -27382,7 +28629,8 @@ def get_long_running_output(pipeline_response): def _update_initial( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any @@ -27410,9 +28658,10 @@ def _update_initial( else: _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - _request = build_virtual_machine_run_commands_update_request( + _request = build_virtual_machine_scale_set_vm_run_commands_update_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -27440,10 +28689,14 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -27451,24 +28704,26 @@ def _update_initial( def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. + :param run_command: Resource create parameters. Required. :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -27484,27 +28739,29 @@ def begin_update( def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. - Required. + :param run_command: Resource create parameters. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) @@ -27517,22 +28774,25 @@ def begin_update( def begin_update( self, resource_group_name: str, - vm_name: str, + vm_scale_set_name: str, + instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the run command. + """The operation to update the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be updated. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. + :param run_command: Resource create parameters. Is either a VirtualMachineRunCommandUpdate type + or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of @@ -27553,7 +28813,8 @@ def begin_update( if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, @@ -27567,13 +28828,20 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -27590,7 +28858,7 @@ def get_long_running_output(pipeline_response): ) def _delete_initial( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -27606,9 +28874,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_delete_request( + _request = build_virtual_machine_scale_set_vm_run_commands_delete_request( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -27633,25 +28902,32 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace def begin_delete( - self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the run command. + """The operation to delete the VMSS VM run command. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_name: The name of the virtual machine where the run command should be deleted. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. + :type resource_group_name: str + :param vm_scale_set_name: The name of the VirtualMachineScaleSet. Required. + :type vm_scale_set_name: str + :param instance_id: The name of the VirtualMachineScaleSetVM. Required. + :type instance_id: str + :param run_command_name: The name of the VirtualMachineRunCommand. Required. :type run_command_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] @@ -27668,7 +28944,8 @@ def begin_delete( if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - vm_name=vm_name, + vm_scale_set_name=vm_scale_set_name, + instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x, y, z: x, @@ -27684,7 +28961,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -27698,28 +28977,42 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + @distributed_trace - def get_by_virtual_machine( - self, - resource_group_name: str, - vm_name: str, - run_command_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineRunCommand: - """The operation to get the run command. + def list( + self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.VirtualMachineExtensionsListResult: + """The operation to get all extensions of a Virtual Machine. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. Required. + :param vm_name: The name of the virtual machine. Required. :type vm_name: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -27734,12 +29027,11 @@ def get_by_virtual_machine( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) - _request = build_virtual_machine_run_commands_get_by_virtual_machine_request( + _request = build_virtual_machine_extensions_list_request( resource_group_name=resource_group_name, vm_name=vm_name, - run_command_name=run_command_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -27759,7 +29051,7 @@ def get_by_virtual_machine( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -27767,29 +29059,30 @@ def get_by_virtual_machine( return deserialized # type: ignore @distributed_trace - def list_by_virtual_machine( - self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands of a Virtual Machine. + def get( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineExtension: + """The operation to get the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_name: The name of the virtual machine containing the run command. Required. + :param vm_name: The name of the virtual machine. Required. :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -27798,89 +29091,48 @@ def list_by_virtual_machine( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( - resource_group_name=resource_group_name, - vm_name=vm_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - return ItemPaged(get_next, extract_data) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) + _request = build_virtual_machine_extensions_get_request( + resource_group_name=resource_group_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) -class VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_11_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_run_commands` attribute. - """ + response = pipeline_response.http_response - models = _models + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -27901,16 +29153,15 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommand") + _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") - _request = build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( + _request = build_virtual_machine_extensions_create_or_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -27937,10 +29188,15 @@ def _create_or_update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -27948,34 +29204,32 @@ def _create_or_update_initial( def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: _models.VirtualMachineRunCommand, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtension, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -27983,34 +29237,32 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: IO[bytes], + vm_name: str, + vm_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: IO[bytes] + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -28018,29 +29270,28 @@ def begin_create_or_update( def begin_create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to create or update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to create or update the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommand type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension + operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. + :type extension_parameters: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension or + IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -28048,17 +29299,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - run_command=run_command, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -28070,35 +29320,36 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( + return LROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineRunCommand]( + return LROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -28119,16 +29370,15 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(run_command, (IOBase, bytes)): - _content = run_command + if isinstance(extension_parameters, (IOBase, bytes)): + _content = extension_parameters else: - _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") + _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") - _request = build_virtual_machine_scale_set_vm_run_commands_update_request( + _request = build_virtual_machine_extensions_update_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -28155,10 +29405,14 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -28166,34 +29420,33 @@ def _update_initial( def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: _models.VirtualMachineRunCommandUpdate, + vm_name: str, + vm_extension_name: str, + extension_parameters: _models.VirtualMachineExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -28201,65 +29454,61 @@ def begin_update( def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: IO[bytes], + vm_name: str, + vm_extension_name: str, + extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type run_command: IO[bytes] + :type resource_group_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Required. + :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Known values are: 'application/json', 'text/json'. Default value is "application/json". + Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + def begin_update( + self, + resource_group_name: str, + vm_name: str, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineRunCommand]: - """The operation to update the VMSS VM run command. + ) -> LROPoller[_models.VirtualMachineExtension]: + """The operation to update the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is - either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. - :type run_command: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommandUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str + :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension + operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. + :type extension_parameters: + ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtensionUpdate or IO[bytes] + :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -28267,17 +29516,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - run_command=run_command, + vm_name=vm_name, + vm_extension_name=vm_extension_name, + extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -28289,30 +29537,37 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( + return LROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.VirtualMachineRunCommand]( + return LROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -28328,11 +29583,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_run_commands_delete_request( + _request = build_virtual_machine_extensions_delete_request( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -28356,27 +29610,31 @@ def _delete_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace def begin_delete( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any + self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the VMSS VM run command. + """The operation to delete the extension. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str + :param vm_name: The name of the virtual machine. Required. + :type vm_name: str + :param vm_extension_name: The name of the virtual machine extension. Required. + :type vm_extension_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -28392,9 +29650,8 @@ def begin_delete( if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, + vm_name=vm_name, + vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -28409,7 +29666,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) # type: ignore if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -28422,171 +29681,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - run_command_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineRunCommand: - """The operation to get the VMSS VM run command. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :param run_command_name: The name of the virtual machine run command. Required. - :type run_command_name: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: VirtualMachineRunCommand or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vm_run_commands_get_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - run_command_name=run_command_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommand"]: - """The operation to get all run commands of an instance in Virtual Machine Scaleset. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param vm_scale_set_name: The name of the VM scale set. Required. - :type vm_scale_set_name: str - :param instance_id: The instance ID of the virtual machine. Required. - :type instance_id: str - :keyword expand: The expand expression to apply on the operation. Default value is None. - :paramtype expand: str - :return: An iterator like instance of either VirtualMachineRunCommand or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_11_01.models.VirtualMachineRunCommand] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-11-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_virtual_machine_scale_set_vm_run_commands_list_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_version.py index 8042a5e50f17..6ba690f28963 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.1.0" +VERSION = "35.0.0" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/__init__.py index c38558c72df3..41713729b15f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/__init__.py @@ -63,6 +63,7 @@ SubResource, SubResourceReadOnly, SystemData, + SystemDataAutoGenerated, UpdateDomain, UpdateDomainListResult, UserAssignedIdentitiesValue, @@ -71,6 +72,7 @@ from ._compute_management_client_enums import ( # type: ignore CloudServiceSlotType, CloudServiceUpgradeMode, + CreatedByType, ExtendedLocationTypes, InstanceViewTypes, StatusLevelTypes, @@ -129,11 +131,13 @@ "SubResource", "SubResourceReadOnly", "SystemData", + "SystemDataAutoGenerated", "UpdateDomain", "UpdateDomainListResult", "UserAssignedIdentitiesValue", "CloudServiceSlotType", "CloudServiceUpgradeMode", + "CreatedByType", "ExtendedLocationTypes", "InstanceViewTypes", "StatusLevelTypes", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_compute_management_client_enums.py index 8447b6e04823..b046d41ecd72 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_compute_management_client_enums.py @@ -38,6 +38,15 @@ class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): SIMULTANEOUS = "Simultaneous" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation.""" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_models_py3.py index 7c7b0dca974a..385f7ba45dab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_11_04/models/_models_py3.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union @@ -128,7 +129,7 @@ class CloudService(_serialization.Model): :vartype tags: dict[str, str] :ivar properties: Cloud service properties. :vartype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceProperties - :ivar system_data: The system meta data relating to this resource. + :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.compute.v2024_11_04.models.SystemData :ivar zones: List of logical availability zone of the resource. List should contain only 1 zone where cloud service should be provisioned. This field is optional. @@ -140,6 +141,7 @@ class CloudService(_serialization.Model): "name": {"readonly": True}, "type": {"readonly": True}, "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { @@ -159,7 +161,6 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.CloudServiceProperties"] = None, - system_data: Optional["_models.SystemData"] = None, zones: Optional[List[str]] = None, **kwargs: Any ) -> None: @@ -170,8 +171,6 @@ def __init__( :paramtype tags: dict[str, str] :keyword properties: Cloud service properties. :paramtype properties: ~azure.mgmt.compute.v2024_11_04.models.CloudServiceProperties - :keyword system_data: The system meta data relating to this resource. - :paramtype system_data: ~azure.mgmt.compute.v2024_11_04.models.SystemData :keyword zones: List of logical availability zone of the resource. List should contain only 1 zone where cloud service should be provisioned. This field is optional. :paramtype zones: list[str] @@ -183,7 +182,7 @@ def __init__( self.location = location self.tags = tags self.properties = properties - self.system_data = system_data + self.system_data = None self.zones = zones @@ -1990,6 +1989,70 @@ def __init__(self, **kwargs: Any) -> None: class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.compute.v2024_11_04.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_04.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.compute.v2024_11_04.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.compute.v2024_11_04.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class SystemDataAutoGenerated(_serialization.Model): """The system meta data relating to this resource. Variables are only populated by the server, and will be ignored when sending a request. diff --git a/sdk/compute/azure-mgmt-compute/generated_samples/virtual_machine_scale_set_examples/virtual_machine_scale_set_vm_list_minimum_set_gen.py b/sdk/compute/azure-mgmt-compute/generated_samples/virtual_machine_scale_set_examples/virtual_machine_scale_set_vm_list_minimum_set_gen.py index 3712e6d79306..9cd167dee301 100644 --- a/sdk/compute/azure-mgmt-compute/generated_samples/virtual_machine_scale_set_examples/virtual_machine_scale_set_vm_list_minimum_set_gen.py +++ b/sdk/compute/azure-mgmt-compute/generated_samples/virtual_machine_scale_set_examples/virtual_machine_scale_set_vm_list_minimum_set_gen.py @@ -32,7 +32,7 @@ def main(): response = client.virtual_machine_scale_set_vms.list( resource_group_name="rgcompute", - virtual_machine_scale_set_name="aaaaaaaaaaaaaaaaaaaaaaaaaaaa", + virtual_machine_scale_set_name="aaaaaaaaaaaaaa", ) for item in response: print(item) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py index ffa4881c7178..c478d9bbe5d0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementAvailabilitySetsOperations(AzureMgmtRecordedTestCase) def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_availability_sets_list_by_subscription(self, resource_group): + response = self.client.availability_sets.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_availability_sets_list(self, resource_group): + response = self.client.availability_sets.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_availability_sets_get(self, resource_group): + response = self.client.availability_sets.get( + resource_group_name=resource_group.name, + availability_set_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_availability_sets_create_or_update(self, resource_group): @@ -46,6 +79,14 @@ def test_availability_sets_create_or_update(self, resource_group): "time": "2020-02-20 00:00:00", } ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachineScaleSetMigrationInfo": { @@ -118,8 +159,8 @@ def test_availability_sets_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_availability_sets_get(self, resource_group): - response = self.client.availability_sets.get( + def test_availability_sets_cancel_migration_to_virtual_machine_scale_set(self, resource_group): + response = self.client.availability_sets.cancel_migration_to_virtual_machine_scale_set( resource_group_name=resource_group.name, availability_set_name="str", api_version="2024-11-01", @@ -130,34 +171,13 @@ def test_availability_sets_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_availability_sets_list_by_subscription(self, resource_group): - response = self.client.availability_sets.list_by_subscription( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_availability_sets_list(self, resource_group): - response = self.client.availability_sets.list( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_availability_sets_list_available_sizes(self, resource_group): - response = self.client.availability_sets.list_available_sizes( + def test_availability_sets_begin_convert_to_virtual_machine_scale_set(self, resource_group): + response = self.client.availability_sets.begin_convert_to_virtual_machine_scale_set( resource_group_name=resource_group.name, availability_set_name="str", api_version="2024-11-01", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -174,18 +194,6 @@ def test_availability_sets_start_migration_to_virtual_machine_scale_set(self, re # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_availability_sets_cancel_migration_to_virtual_machine_scale_set(self, resource_group): - response = self.client.availability_sets.cancel_migration_to_virtual_machine_scale_set( - resource_group_name=resource_group.name, - availability_set_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_availability_sets_validate_migration_to_virtual_machine_scale_set(self, resource_group): @@ -201,12 +209,12 @@ def test_availability_sets_validate_migration_to_virtual_machine_scale_set(self, @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_availability_sets_begin_convert_to_virtual_machine_scale_set(self, resource_group): - response = self.client.availability_sets.begin_convert_to_virtual_machine_scale_set( + def test_availability_sets_list_available_sizes(self, resource_group): + response = self.client.availability_sets.list_available_sizes( resource_group_name=resource_group.name, availability_set_name="str", api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py index 45731b30b4ee..18ac70c0f33a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_availability_sets_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementAvailabilitySetsOperationsAsync(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_availability_sets_list_by_subscription(self, resource_group): + response = self.client.availability_sets.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_availability_sets_list(self, resource_group): + response = self.client.availability_sets.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_availability_sets_get(self, resource_group): + response = await self.client.availability_sets.get( + resource_group_name=resource_group.name, + availability_set_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_availability_sets_create_or_update(self, resource_group): @@ -47,6 +80,14 @@ async def test_availability_sets_create_or_update(self, resource_group): "time": "2020-02-20 00:00:00", } ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachineScaleSetMigrationInfo": { @@ -119,8 +160,8 @@ async def test_availability_sets_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_availability_sets_get(self, resource_group): - response = await self.client.availability_sets.get( + async def test_availability_sets_cancel_migration_to_virtual_machine_scale_set(self, resource_group): + response = await self.client.availability_sets.cancel_migration_to_virtual_machine_scale_set( resource_group_name=resource_group.name, availability_set_name="str", api_version="2024-11-01", @@ -131,34 +172,15 @@ async def test_availability_sets_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_availability_sets_list_by_subscription(self, resource_group): - response = self.client.availability_sets.list_by_subscription( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_availability_sets_list(self, resource_group): - response = self.client.availability_sets.list( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... + async def test_availability_sets_begin_convert_to_virtual_machine_scale_set(self, resource_group): + response = await ( + await self.client.availability_sets.begin_convert_to_virtual_machine_scale_set( + resource_group_name=resource_group.name, + availability_set_name="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_availability_sets_list_available_sizes(self, resource_group): - response = self.client.availability_sets.list_available_sizes( - resource_group_name=resource_group.name, - availability_set_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] # please add some check logic here by yourself # ... @@ -177,10 +199,11 @@ async def test_availability_sets_start_migration_to_virtual_machine_scale_set(se @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_availability_sets_cancel_migration_to_virtual_machine_scale_set(self, resource_group): - response = await self.client.availability_sets.cancel_migration_to_virtual_machine_scale_set( + async def test_availability_sets_validate_migration_to_virtual_machine_scale_set(self, resource_group): + response = await self.client.availability_sets.validate_migration_to_virtual_machine_scale_set( resource_group_name=resource_group.name, availability_set_name="str", + parameters={"virtualMachineScaleSetFlexible": {"id": "str"}}, api_version="2024-11-01", ) @@ -189,27 +212,12 @@ async def test_availability_sets_cancel_migration_to_virtual_machine_scale_set(s @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_availability_sets_validate_migration_to_virtual_machine_scale_set(self, resource_group): - response = await self.client.availability_sets.validate_migration_to_virtual_machine_scale_set( + async def test_availability_sets_list_available_sizes(self, resource_group): + response = self.client.availability_sets.list_available_sizes( resource_group_name=resource_group.name, availability_set_name="str", - parameters={"virtualMachineScaleSetFlexible": {"id": "str"}}, api_version="2024-11-01", ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_availability_sets_begin_convert_to_virtual_machine_scale_set(self, resource_group): - response = await ( - await self.client.availability_sets.begin_convert_to_virtual_machine_scale_set( - resource_group_name=resource_group.name, - availability_set_name="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py index 790ba618ad0f..1c1c98cf3c8d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementCapacityReservationGroupsOperations(AzureMgmtRecorded def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capacity_reservation_groups_list_by_subscription(self, resource_group): + response = self.client.capacity_reservation_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capacity_reservation_groups_list_by_resource_group(self, resource_group): + response = self.client.capacity_reservation_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capacity_reservation_groups_get(self, resource_group): + response = self.client.capacity_reservation_groups.get( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_capacity_reservation_groups_create_or_update(self, resource_group): @@ -48,6 +81,14 @@ def test_capacity_reservation_groups_create_or_update(self, resource_group): }, "name": "str", "sharingProfile": {"subscriptionIds": [{"id": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachinesAssociated": [{"id": "str"}], @@ -106,36 +147,3 @@ def test_capacity_reservation_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capacity_reservation_groups_get(self, resource_group): - response = self.client.capacity_reservation_groups.get( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capacity_reservation_groups_list_by_resource_group(self, resource_group): - response = self.client.capacity_reservation_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capacity_reservation_groups_list_by_subscription(self, resource_group): - response = self.client.capacity_reservation_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py index 104d59afec66..75ddc42a15f9 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservation_groups_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementCapacityReservationGroupsOperationsAsync(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capacity_reservation_groups_list_by_subscription(self, resource_group): + response = self.client.capacity_reservation_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capacity_reservation_groups_list_by_resource_group(self, resource_group): + response = self.client.capacity_reservation_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capacity_reservation_groups_get(self, resource_group): + response = await self.client.capacity_reservation_groups.get( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_capacity_reservation_groups_create_or_update(self, resource_group): @@ -49,6 +82,14 @@ async def test_capacity_reservation_groups_create_or_update(self, resource_group }, "name": "str", "sharingProfile": {"subscriptionIds": [{"id": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachinesAssociated": [{"id": "str"}], @@ -107,36 +148,3 @@ async def test_capacity_reservation_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capacity_reservation_groups_get(self, resource_group): - response = await self.client.capacity_reservation_groups.get( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capacity_reservation_groups_list_by_resource_group(self, resource_group): - response = self.client.capacity_reservation_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capacity_reservation_groups_list_by_subscription(self, resource_group): - response = self.client.capacity_reservation_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py index 919fbefb82ef..38f467118ade 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations.py @@ -18,6 +18,31 @@ class TestComputeManagementCapacityReservationsOperations(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capacity_reservations_list_by_capacity_reservation_group(self, resource_group): + response = self.client.capacity_reservations.list_by_capacity_reservation_group( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capacity_reservations_get(self, resource_group): + response = self.client.capacity_reservations.get( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + capacity_reservation_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_capacity_reservations_begin_create_or_update(self, resource_group): @@ -46,6 +71,14 @@ def test_capacity_reservations_begin_create_or_update(self, resource_group): "provisioningState": "str", "provisioningTime": "2020-02-20 00:00:00", "reservationId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -105,28 +138,3 @@ def test_capacity_reservations_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capacity_reservations_get(self, resource_group): - response = self.client.capacity_reservations.get( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - capacity_reservation_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capacity_reservations_list_by_capacity_reservation_group(self, resource_group): - response = self.client.capacity_reservations.list_by_capacity_reservation_group( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py index 4dd700c1322d..d35c12a92be0 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_capacity_reservations_operations_async.py @@ -19,6 +19,31 @@ class TestComputeManagementCapacityReservationsOperationsAsync(AzureMgmtRecorded def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capacity_reservations_list_by_capacity_reservation_group(self, resource_group): + response = self.client.capacity_reservations.list_by_capacity_reservation_group( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capacity_reservations_get(self, resource_group): + response = await self.client.capacity_reservations.get( + resource_group_name=resource_group.name, + capacity_reservation_group_name="str", + capacity_reservation_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_capacity_reservations_begin_create_or_update(self, resource_group): @@ -48,6 +73,14 @@ async def test_capacity_reservations_begin_create_or_update(self, resource_group "provisioningState": "str", "provisioningTime": "2020-02-20 00:00:00", "reservationId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -112,28 +145,3 @@ async def test_capacity_reservations_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capacity_reservations_get(self, resource_group): - response = await self.client.capacity_reservations.get( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - capacity_reservation_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capacity_reservations_list_by_capacity_reservation_group(self, resource_group): - response = self.client.capacity_reservations.list_by_capacity_reservation_group( - resource_group_name=resource_group.name, - capacity_reservation_group_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py index d36e68d632c2..f5fecefe839d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementDedicatedHostGroupsOperations(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dedicated_host_groups_list_by_subscription(self, resource_group): + response = self.client.dedicated_host_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dedicated_host_groups_list_by_resource_group(self, resource_group): + response = self.client.dedicated_host_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dedicated_host_groups_get(self, resource_group): + response = self.client.dedicated_host_groups.get( + resource_group_name=resource_group.name, + host_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_dedicated_host_groups_create_or_update(self, resource_group): @@ -50,6 +83,14 @@ def test_dedicated_host_groups_create_or_update(self, resource_group): "name": "str", "platformFaultDomainCount": 0, "supportAutomaticPlacement": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "zones": ["str"], @@ -109,36 +150,3 @@ def test_dedicated_host_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_dedicated_host_groups_get(self, resource_group): - response = self.client.dedicated_host_groups.get( - resource_group_name=resource_group.name, - host_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_dedicated_host_groups_list_by_resource_group(self, resource_group): - response = self.client.dedicated_host_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_dedicated_host_groups_list_by_subscription(self, resource_group): - response = self.client.dedicated_host_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py index c70854c47514..c47664beb1b2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_host_groups_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementDedicatedHostGroupsOperationsAsync(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dedicated_host_groups_list_by_subscription(self, resource_group): + response = self.client.dedicated_host_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dedicated_host_groups_list_by_resource_group(self, resource_group): + response = self.client.dedicated_host_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dedicated_host_groups_get(self, resource_group): + response = await self.client.dedicated_host_groups.get( + resource_group_name=resource_group.name, + host_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_dedicated_host_groups_create_or_update(self, resource_group): @@ -51,6 +84,14 @@ async def test_dedicated_host_groups_create_or_update(self, resource_group): "name": "str", "platformFaultDomainCount": 0, "supportAutomaticPlacement": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "zones": ["str"], @@ -110,36 +151,3 @@ async def test_dedicated_host_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_dedicated_host_groups_get(self, resource_group): - response = await self.client.dedicated_host_groups.get( - resource_group_name=resource_group.name, - host_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_dedicated_host_groups_list_by_resource_group(self, resource_group): - response = self.client.dedicated_host_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_dedicated_host_groups_list_by_subscription(self, resource_group): - response = self.client.dedicated_host_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py index 3743fe349c52..e3a492853617 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations.py @@ -18,6 +18,31 @@ class TestComputeManagementDedicatedHostsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dedicated_hosts_list_by_host_group(self, resource_group): + response = self.client.dedicated_hosts.list_by_host_group( + resource_group_name=resource_group.name, + host_group_name="str", + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_dedicated_hosts_get(self, resource_group): + response = self.client.dedicated_hosts.get( + resource_group_name=resource_group.name, + host_group_name="str", + host_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_dedicated_hosts_begin_create_or_update(self, resource_group): @@ -49,6 +74,14 @@ def test_dedicated_hosts_begin_create_or_update(self, resource_group): "platformFaultDomain": 0, "provisioningState": "str", "provisioningTime": "2020-02-20 00:00:00", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -113,42 +146,17 @@ def test_dedicated_hosts_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_dedicated_hosts_get(self, resource_group): - response = self.client.dedicated_hosts.get( + def test_dedicated_hosts_list_available_sizes(self, resource_group): + response = self.client.dedicated_hosts.list_available_sizes( resource_group_name=resource_group.name, host_group_name="str", host_name="str", api_version="2024-11-01", ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_dedicated_hosts_list_by_host_group(self, resource_group): - response = self.client.dedicated_hosts.list_by_host_group( - resource_group_name=resource_group.name, - host_group_name="str", - api_version="2024-11-01", - ) result = [r for r in response] # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_dedicated_hosts_begin_restart(self, resource_group): - response = self.client.dedicated_hosts.begin_restart( - resource_group_name=resource_group.name, - host_group_name="str", - host_name="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_dedicated_hosts_begin_redeploy(self, resource_group): @@ -164,13 +172,13 @@ def test_dedicated_hosts_begin_redeploy(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_dedicated_hosts_list_available_sizes(self, resource_group): - response = self.client.dedicated_hosts.list_available_sizes( + def test_dedicated_hosts_begin_restart(self, resource_group): + response = self.client.dedicated_hosts.begin_restart( resource_group_name=resource_group.name, host_group_name="str", host_name="str", api_version="2024-11-01", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py index 2b703bdba4d4..142b29b70e22 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_dedicated_hosts_operations_async.py @@ -19,6 +19,31 @@ class TestComputeManagementDedicatedHostsOperationsAsync(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dedicated_hosts_list_by_host_group(self, resource_group): + response = self.client.dedicated_hosts.list_by_host_group( + resource_group_name=resource_group.name, + host_group_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_dedicated_hosts_get(self, resource_group): + response = await self.client.dedicated_hosts.get( + resource_group_name=resource_group.name, + host_group_name="str", + host_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_dedicated_hosts_begin_create_or_update(self, resource_group): @@ -51,6 +76,14 @@ async def test_dedicated_hosts_begin_create_or_update(self, resource_group): "platformFaultDomain": 0, "provisioningState": "str", "provisioningTime": "2020-02-20 00:00:00", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -120,34 +153,22 @@ async def test_dedicated_hosts_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_dedicated_hosts_get(self, resource_group): - response = await self.client.dedicated_hosts.get( + async def test_dedicated_hosts_list_available_sizes(self, resource_group): + response = self.client.dedicated_hosts.list_available_sizes( resource_group_name=resource_group.name, host_group_name="str", host_name="str", api_version="2024-11-01", ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_dedicated_hosts_list_by_host_group(self, resource_group): - response = self.client.dedicated_hosts.list_by_host_group( - resource_group_name=resource_group.name, - host_group_name="str", - api_version="2024-11-01", - ) result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_dedicated_hosts_begin_restart(self, resource_group): + async def test_dedicated_hosts_begin_redeploy(self, resource_group): response = await ( - await self.client.dedicated_hosts.begin_restart( + await self.client.dedicated_hosts.begin_redeploy( resource_group_name=resource_group.name, host_group_name="str", host_name="str", @@ -160,9 +181,9 @@ async def test_dedicated_hosts_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_dedicated_hosts_begin_redeploy(self, resource_group): + async def test_dedicated_hosts_begin_restart(self, resource_group): response = await ( - await self.client.dedicated_hosts.begin_redeploy( + await self.client.dedicated_hosts.begin_restart( resource_group_name=resource_group.name, host_group_name="str", host_name="str", @@ -172,16 +193,3 @@ async def test_dedicated_hosts_begin_redeploy(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_dedicated_hosts_list_available_sizes(self, resource_group): - response = self.client.dedicated_hosts.list_available_sizes( - resource_group_name=resource_group.name, - host_group_name="str", - host_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py index eb9f8554116d..abcfc43a14ab 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementImagesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_images_list(self, resource_group): + response = self.client.images.list( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_images_list_by_resource_group(self, resource_group): + response = self.client.images.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_images_get(self, resource_group): + response = self.client.images.get( + resource_group_name=resource_group.name, + image_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_images_begin_create_or_update(self, resource_group): @@ -58,6 +91,14 @@ def test_images_begin_create_or_update(self, resource_group): }, "zoneResilient": bool, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -122,36 +163,3 @@ def test_images_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_images_get(self, resource_group): - response = self.client.images.get( - resource_group_name=resource_group.name, - image_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_images_list_by_resource_group(self, resource_group): - response = self.client.images.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_images_list(self, resource_group): - response = self.client.images.list( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py index 7b9d7f38918f..1c424610f662 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_images_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementImagesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_images_list(self, resource_group): + response = self.client.images.list( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_images_list_by_resource_group(self, resource_group): + response = self.client.images.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_images_get(self, resource_group): + response = await self.client.images.get( + resource_group_name=resource_group.name, + image_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_images_begin_create_or_update(self, resource_group): @@ -60,6 +93,14 @@ async def test_images_begin_create_or_update(self, resource_group): }, "zoneResilient": bool, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -129,36 +170,3 @@ async def test_images_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_images_get(self, resource_group): - response = await self.client.images.get( - resource_group_name=resource_group.name, - image_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_images_list_by_resource_group(self, resource_group): - response = self.client.images.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_images_list(self, resource_group): - response = self.client.images.list( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py index 36326323ffc4..1e8b01f49c31 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementProximityPlacementGroupsOperations(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_proximity_placement_groups_list_by_subscription(self, resource_group): + response = self.client.proximity_placement_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_proximity_placement_groups_list_by_resource_group(self, resource_group): + response = self.client.proximity_placement_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_proximity_placement_groups_get(self, resource_group): + response = self.client.proximity_placement_groups.get( + resource_group_name=resource_group.name, + proximity_placement_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_proximity_placement_groups_create_or_update(self, resource_group): @@ -49,6 +82,14 @@ def test_proximity_placement_groups_create_or_update(self, resource_group): "intent": {"vmSizes": ["str"]}, "name": "str", "proximityPlacementGroupType": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachineScaleSets": [ @@ -107,36 +148,3 @@ def test_proximity_placement_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_proximity_placement_groups_get(self, resource_group): - response = self.client.proximity_placement_groups.get( - resource_group_name=resource_group.name, - proximity_placement_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_proximity_placement_groups_list_by_subscription(self, resource_group): - response = self.client.proximity_placement_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_proximity_placement_groups_list_by_resource_group(self, resource_group): - response = self.client.proximity_placement_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py index ee1b92c7128a..382d00cf7e19 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_proximity_placement_groups_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementProximityPlacementGroupsOperationsAsync(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_proximity_placement_groups_list_by_subscription(self, resource_group): + response = self.client.proximity_placement_groups.list_by_subscription( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_proximity_placement_groups_list_by_resource_group(self, resource_group): + response = self.client.proximity_placement_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_proximity_placement_groups_get(self, resource_group): + response = await self.client.proximity_placement_groups.get( + resource_group_name=resource_group.name, + proximity_placement_group_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_proximity_placement_groups_create_or_update(self, resource_group): @@ -50,6 +83,14 @@ async def test_proximity_placement_groups_create_or_update(self, resource_group) "intent": {"vmSizes": ["str"]}, "name": "str", "proximityPlacementGroupType": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "virtualMachineScaleSets": [ @@ -108,36 +149,3 @@ async def test_proximity_placement_groups_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_proximity_placement_groups_get(self, resource_group): - response = await self.client.proximity_placement_groups.get( - resource_group_name=resource_group.name, - proximity_placement_group_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_proximity_placement_groups_list_by_subscription(self, resource_group): - response = self.client.proximity_placement_groups.list_by_subscription( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_proximity_placement_groups_list_by_resource_group(self, resource_group): - response = self.client.proximity_placement_groups.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py index 235385831fb1..33d58b69721a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations.py @@ -18,6 +18,39 @@ class TestComputeManagementRestorePointCollectionsOperations(AzureMgmtRecordedTe def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restore_point_collections_list_all(self, resource_group): + response = self.client.restore_point_collections.list_all( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restore_point_collections_list(self, resource_group): + response = self.client.restore_point_collections.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restore_point_collections_get(self, resource_group): + response = self.client.restore_point_collections.get( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_restore_point_collections_create_or_update(self, resource_group): @@ -193,11 +226,27 @@ def test_restore_point_collections_create_or_update(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", } ], "source": {"id": "str", "location": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -379,6 +428,14 @@ def test_restore_point_collections_update(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", } @@ -403,36 +460,3 @@ def test_restore_point_collections_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_restore_point_collections_get(self, resource_group): - response = self.client.restore_point_collections.get( - resource_group_name=resource_group.name, - restore_point_collection_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_restore_point_collections_list(self, resource_group): - response = self.client.restore_point_collections.list( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_restore_point_collections_list_all(self, resource_group): - response = self.client.restore_point_collections.list_all( - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py index 441bdeacd7c4..03ef773cc144 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_point_collections_operations_async.py @@ -19,6 +19,39 @@ class TestComputeManagementRestorePointCollectionsOperationsAsync(AzureMgmtRecor def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restore_point_collections_list_all(self, resource_group): + response = self.client.restore_point_collections.list_all( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restore_point_collections_list(self, resource_group): + response = self.client.restore_point_collections.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restore_point_collections_get(self, resource_group): + response = await self.client.restore_point_collections.get( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_restore_point_collections_create_or_update(self, resource_group): @@ -194,11 +227,27 @@ async def test_restore_point_collections_create_or_update(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", } ], "source": {"id": "str", "location": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -380,6 +429,14 @@ async def test_restore_point_collections_update(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", } @@ -406,36 +463,3 @@ async def test_restore_point_collections_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_restore_point_collections_get(self, resource_group): - response = await self.client.restore_point_collections.get( - resource_group_name=resource_group.name, - restore_point_collection_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_restore_point_collections_list(self, resource_group): - response = self.client.restore_point_collections.list( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_restore_point_collections_list_all(self, resource_group): - response = self.client.restore_point_collections.list_all( - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py index 2a5ff310e69c..4da05bdfd1ce 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations.py @@ -18,6 +18,19 @@ class TestComputeManagementRestorePointsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restore_points_get(self, resource_group): + response = self.client.restore_points.get( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + restore_point_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_restore_points_begin_create(self, resource_group): @@ -184,6 +197,14 @@ def test_restore_points_begin_create(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", }, @@ -205,16 +226,3 @@ def test_restore_points_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_restore_points_get(self, resource_group): - response = self.client.restore_points.get( - resource_group_name=resource_group.name, - restore_point_collection_name="str", - restore_point_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py index 6bee2d4653ba..1bb94068c6ab 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_restore_points_operations_async.py @@ -19,6 +19,19 @@ class TestComputeManagementRestorePointsOperationsAsync(AzureMgmtRecordedTestCas def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restore_points_get(self, resource_group): + response = await self.client.restore_points.get( + resource_group_name=resource_group.name, + restore_point_collection_name="str", + restore_point_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_restore_points_begin_create(self, resource_group): @@ -189,6 +202,14 @@ async def test_restore_points_begin_create(self, resource_group): "vmId": "str", }, "sourceRestorePoint": {"id": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "timeCreated": "2020-02-20 00:00:00", "type": "str", }, @@ -213,16 +234,3 @@ async def test_restore_points_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_restore_points_get(self, resource_group): - response = await self.client.restore_points.get( - resource_group_name=resource_group.name, - restore_point_collection_name="str", - restore_point_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py index 0469597c756f..770b3d2568c3 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations.py @@ -39,6 +39,18 @@ def test_ssh_public_keys_list_by_resource_group(self, resource_group): # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_ssh_public_keys_get(self, resource_group): + response = self.client.ssh_public_keys.get( + resource_group_name=resource_group.name, + ssh_public_key_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_ssh_public_keys_create(self, resource_group): @@ -50,6 +62,14 @@ def test_ssh_public_keys_create(self, resource_group): "id": "str", "name": "str", "publicKey": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -84,18 +104,6 @@ def test_ssh_public_keys_delete(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_ssh_public_keys_get(self, resource_group): - response = self.client.ssh_public_keys.get( - resource_group_name=resource_group.name, - ssh_public_key_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_ssh_public_keys_generate_key_pair(self, resource_group): diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py index ab9701888f12..7aa5bc3f20c5 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_ssh_public_keys_operations_async.py @@ -40,6 +40,18 @@ async def test_ssh_public_keys_list_by_resource_group(self, resource_group): # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_ssh_public_keys_get(self, resource_group): + response = await self.client.ssh_public_keys.get( + resource_group_name=resource_group.name, + ssh_public_key_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_ssh_public_keys_create(self, resource_group): @@ -51,6 +63,14 @@ async def test_ssh_public_keys_create(self, resource_group): "id": "str", "name": "str", "publicKey": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, @@ -85,18 +105,6 @@ async def test_ssh_public_keys_delete(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_ssh_public_keys_get(self, resource_group): - response = await self.client.ssh_public_keys.get( - resource_group_name=resource_group.name, - ssh_public_key_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_ssh_public_keys_generate_key_pair(self, resource_group): diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py index 06822439184c..159582a87dda 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations.py @@ -20,12 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_extension_images_get(self, resource_group): - response = self.client.virtual_machine_extension_images.get( + def test_virtual_machine_extension_images_list_types(self, resource_group): + response = self.client.virtual_machine_extension_images.list_types( location="str", publisher_name="str", - type="str", - version="str", api_version="2024-11-01", ) @@ -34,10 +32,11 @@ def test_virtual_machine_extension_images_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_extension_images_list_types(self, resource_group): - response = self.client.virtual_machine_extension_images.list_types( + def test_virtual_machine_extension_images_list_versions(self, resource_group): + response = self.client.virtual_machine_extension_images.list_versions( location="str", publisher_name="str", + type="str", api_version="2024-11-01", ) @@ -46,11 +45,12 @@ def test_virtual_machine_extension_images_list_types(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_extension_images_list_versions(self, resource_group): - response = self.client.virtual_machine_extension_images.list_versions( + def test_virtual_machine_extension_images_get(self, resource_group): + response = self.client.virtual_machine_extension_images.get( location="str", publisher_name="str", type="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py index 70e87b95d9c1..9e5e4f48bf01 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extension_images_operations_async.py @@ -21,12 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_extension_images_get(self, resource_group): - response = await self.client.virtual_machine_extension_images.get( + async def test_virtual_machine_extension_images_list_types(self, resource_group): + response = await self.client.virtual_machine_extension_images.list_types( location="str", publisher_name="str", - type="str", - version="str", api_version="2024-11-01", ) @@ -35,10 +33,11 @@ async def test_virtual_machine_extension_images_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_extension_images_list_types(self, resource_group): - response = await self.client.virtual_machine_extension_images.list_types( + async def test_virtual_machine_extension_images_list_versions(self, resource_group): + response = await self.client.virtual_machine_extension_images.list_versions( location="str", publisher_name="str", + type="str", api_version="2024-11-01", ) @@ -47,11 +46,12 @@ async def test_virtual_machine_extension_images_list_types(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_extension_images_list_versions(self, resource_group): - response = await self.client.virtual_machine_extension_images.list_versions( + async def test_virtual_machine_extension_images_get(self, resource_group): + response = await self.client.virtual_machine_extension_images.get( location="str", publisher_name="str", type="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py index 21ee1e5bfd9f..66df37fdbdbd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations.py @@ -18,6 +18,31 @@ class TestComputeManagementVirtualMachineExtensionsOperations(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_extensions_list(self, resource_group): + response = self.client.virtual_machine_extensions.list( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_extensions_get(self, resource_group): + response = self.client.virtual_machine_extensions.get( + resource_group_name=resource_group.name, + vm_name="str", + vm_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_extensions_begin_create_or_update(self, resource_group): @@ -26,6 +51,7 @@ def test_virtual_machine_extensions_begin_create_or_update(self, resource_group) vm_name="str", vm_extension_name="str", extension_parameters={ + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -53,7 +79,6 @@ def test_virtual_machine_extensions_begin_create_or_update(self, resource_group) "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -62,6 +87,14 @@ def test_virtual_machine_extensions_begin_create_or_update(self, resource_group) "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -110,28 +143,3 @@ def test_virtual_machine_extensions_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_extensions_get(self, resource_group): - response = self.client.virtual_machine_extensions.get( - resource_group_name=resource_group.name, - vm_name="str", - vm_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_extensions_list(self, resource_group): - response = self.client.virtual_machine_extensions.list( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py index b0eb74a09db4..b8e7c8178582 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_extensions_operations_async.py @@ -19,6 +19,31 @@ class TestComputeManagementVirtualMachineExtensionsOperationsAsync(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_extensions_list(self, resource_group): + response = await self.client.virtual_machine_extensions.list( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_extensions_get(self, resource_group): + response = await self.client.virtual_machine_extensions.get( + resource_group_name=resource_group.name, + vm_name="str", + vm_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_extensions_begin_create_or_update(self, resource_group): @@ -28,6 +53,7 @@ async def test_virtual_machine_extensions_begin_create_or_update(self, resource_ vm_name="str", vm_extension_name="str", extension_parameters={ + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -55,7 +81,6 @@ async def test_virtual_machine_extensions_begin_create_or_update(self, resource_ "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -64,6 +89,14 @@ async def test_virtual_machine_extensions_begin_create_or_update(self, resource_ "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -117,28 +150,3 @@ async def test_virtual_machine_extensions_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_extensions_get(self, resource_group): - response = await self.client.virtual_machine_extensions.get( - resource_group_name=resource_group.name, - vm_name="str", - vm_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_extensions_list(self, resource_group): - response = await self.client.virtual_machine_extensions.list( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py index c298c5af4872..b24680890026 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations.py @@ -20,14 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_edge_zone_get(self, resource_group): - response = self.client.virtual_machine_images_edge_zone.get( + def test_virtual_machine_images_edge_zone_list_publishers(self, resource_group): + response = self.client.virtual_machine_images_edge_zone.list_publishers( location="str", edge_zone="str", - publisher_name="str", - offer="str", - skus="str", - version="str", api_version="2024-11-01", ) @@ -36,13 +32,11 @@ def test_virtual_machine_images_edge_zone_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_edge_zone_list(self, resource_group): - response = self.client.virtual_machine_images_edge_zone.list( + def test_virtual_machine_images_edge_zone_list_offers(self, resource_group): + response = self.client.virtual_machine_images_edge_zone.list_offers( location="str", edge_zone="str", publisher_name="str", - offer="str", - skus="str", api_version="2024-11-01", ) @@ -51,11 +45,12 @@ def test_virtual_machine_images_edge_zone_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_edge_zone_list_offers(self, resource_group): - response = self.client.virtual_machine_images_edge_zone.list_offers( + def test_virtual_machine_images_edge_zone_list_skus(self, resource_group): + response = self.client.virtual_machine_images_edge_zone.list_skus( location="str", edge_zone="str", publisher_name="str", + offer="str", api_version="2024-11-01", ) @@ -64,10 +59,13 @@ def test_virtual_machine_images_edge_zone_list_offers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_edge_zone_list_publishers(self, resource_group): - response = self.client.virtual_machine_images_edge_zone.list_publishers( + def test_virtual_machine_images_edge_zone_list(self, resource_group): + response = self.client.virtual_machine_images_edge_zone.list( location="str", edge_zone="str", + publisher_name="str", + offer="str", + skus="str", api_version="2024-11-01", ) @@ -76,12 +74,14 @@ def test_virtual_machine_images_edge_zone_list_publishers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_edge_zone_list_skus(self, resource_group): - response = self.client.virtual_machine_images_edge_zone.list_skus( + def test_virtual_machine_images_edge_zone_get(self, resource_group): + response = self.client.virtual_machine_images_edge_zone.get( location="str", edge_zone="str", publisher_name="str", offer="str", + skus="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py index 0e91202d2b72..ccb3d45e3cfe 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_edge_zone_operations_async.py @@ -21,14 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_edge_zone_get(self, resource_group): - response = await self.client.virtual_machine_images_edge_zone.get( + async def test_virtual_machine_images_edge_zone_list_publishers(self, resource_group): + response = await self.client.virtual_machine_images_edge_zone.list_publishers( location="str", edge_zone="str", - publisher_name="str", - offer="str", - skus="str", - version="str", api_version="2024-11-01", ) @@ -37,13 +33,11 @@ async def test_virtual_machine_images_edge_zone_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_edge_zone_list(self, resource_group): - response = await self.client.virtual_machine_images_edge_zone.list( + async def test_virtual_machine_images_edge_zone_list_offers(self, resource_group): + response = await self.client.virtual_machine_images_edge_zone.list_offers( location="str", edge_zone="str", publisher_name="str", - offer="str", - skus="str", api_version="2024-11-01", ) @@ -52,11 +46,12 @@ async def test_virtual_machine_images_edge_zone_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_edge_zone_list_offers(self, resource_group): - response = await self.client.virtual_machine_images_edge_zone.list_offers( + async def test_virtual_machine_images_edge_zone_list_skus(self, resource_group): + response = await self.client.virtual_machine_images_edge_zone.list_skus( location="str", edge_zone="str", publisher_name="str", + offer="str", api_version="2024-11-01", ) @@ -65,10 +60,13 @@ async def test_virtual_machine_images_edge_zone_list_offers(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_edge_zone_list_publishers(self, resource_group): - response = await self.client.virtual_machine_images_edge_zone.list_publishers( + async def test_virtual_machine_images_edge_zone_list(self, resource_group): + response = await self.client.virtual_machine_images_edge_zone.list( location="str", edge_zone="str", + publisher_name="str", + offer="str", + skus="str", api_version="2024-11-01", ) @@ -77,12 +75,14 @@ async def test_virtual_machine_images_edge_zone_list_publishers(self, resource_g @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_edge_zone_list_skus(self, resource_group): - response = await self.client.virtual_machine_images_edge_zone.list_skus( + async def test_virtual_machine_images_edge_zone_get(self, resource_group): + response = await self.client.virtual_machine_images_edge_zone.get( location="str", edge_zone="str", publisher_name="str", offer="str", + skus="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py index 5a9125745c0b..3919771472fc 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations.py @@ -20,13 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_get(self, resource_group): - response = self.client.virtual_machine_images.get( + def test_virtual_machine_images_list_by_edge_zone(self, resource_group): + response = self.client.virtual_machine_images.list_by_edge_zone( location="str", - publisher_name="str", - offer="str", - skus="str", - version="str", + edge_zone="str", api_version="2024-11-01", ) @@ -35,12 +32,9 @@ def test_virtual_machine_images_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_list(self, resource_group): - response = self.client.virtual_machine_images.list( + def test_virtual_machine_images_list_publishers(self, resource_group): + response = self.client.virtual_machine_images.list_publishers( location="str", - publisher_name="str", - offer="str", - skus="str", api_version="2024-11-01", ) @@ -61,9 +55,11 @@ def test_virtual_machine_images_list_offers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_list_publishers(self, resource_group): - response = self.client.virtual_machine_images.list_publishers( + def test_virtual_machine_images_list_skus(self, resource_group): + response = self.client.virtual_machine_images.list_skus( location="str", + publisher_name="str", + offer="str", api_version="2024-11-01", ) @@ -72,11 +68,12 @@ def test_virtual_machine_images_list_publishers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_list_skus(self, resource_group): - response = self.client.virtual_machine_images.list_skus( + def test_virtual_machine_images_list(self, resource_group): + response = self.client.virtual_machine_images.list( location="str", publisher_name="str", offer="str", + skus="str", api_version="2024-11-01", ) @@ -85,10 +82,13 @@ def test_virtual_machine_images_list_skus(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_images_list_by_edge_zone(self, resource_group): - response = self.client.virtual_machine_images.list_by_edge_zone( + def test_virtual_machine_images_get(self, resource_group): + response = self.client.virtual_machine_images.get( location="str", - edge_zone="str", + publisher_name="str", + offer="str", + skus="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py index 5d1fd72b1588..f6bbe280718f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_images_operations_async.py @@ -21,13 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_get(self, resource_group): - response = await self.client.virtual_machine_images.get( + async def test_virtual_machine_images_list_by_edge_zone(self, resource_group): + response = await self.client.virtual_machine_images.list_by_edge_zone( location="str", - publisher_name="str", - offer="str", - skus="str", - version="str", + edge_zone="str", api_version="2024-11-01", ) @@ -36,12 +33,9 @@ async def test_virtual_machine_images_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_list(self, resource_group): - response = await self.client.virtual_machine_images.list( + async def test_virtual_machine_images_list_publishers(self, resource_group): + response = await self.client.virtual_machine_images.list_publishers( location="str", - publisher_name="str", - offer="str", - skus="str", api_version="2024-11-01", ) @@ -62,9 +56,11 @@ async def test_virtual_machine_images_list_offers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_list_publishers(self, resource_group): - response = await self.client.virtual_machine_images.list_publishers( + async def test_virtual_machine_images_list_skus(self, resource_group): + response = await self.client.virtual_machine_images.list_skus( location="str", + publisher_name="str", + offer="str", api_version="2024-11-01", ) @@ -73,11 +69,12 @@ async def test_virtual_machine_images_list_publishers(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_list_skus(self, resource_group): - response = await self.client.virtual_machine_images.list_skus( + async def test_virtual_machine_images_list(self, resource_group): + response = await self.client.virtual_machine_images.list( location="str", publisher_name="str", offer="str", + skus="str", api_version="2024-11-01", ) @@ -86,10 +83,13 @@ async def test_virtual_machine_images_list_skus(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_images_list_by_edge_zone(self, resource_group): - response = await self.client.virtual_machine_images.list_by_edge_zone( + async def test_virtual_machine_images_get(self, resource_group): + response = await self.client.virtual_machine_images.get( location="str", - edge_zone="str", + publisher_name="str", + offer="str", + skus="str", + version="str", api_version="2024-11-01", ) diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py index caf662e06726..31c6237e0100 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations.py @@ -41,6 +41,31 @@ def test_virtual_machine_run_commands_get(self, resource_group): # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_run_commands_list_by_virtual_machine(self, resource_group): + response = self.client.virtual_machine_run_commands.list_by_virtual_machine( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_run_commands_get_by_virtual_machine(self, resource_group): + response = self.client.virtual_machine_run_commands.get_by_virtual_machine( + resource_group_name=resource_group.name, + vm_name="str", + run_command_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_run_commands_begin_create_or_update(self, resource_group): @@ -50,7 +75,7 @@ def test_virtual_machine_run_commands_begin_create_or_update(self, resource_grou run_command_name="str", run_command={ "location": "str", - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "id": "str", @@ -86,9 +111,17 @@ def test_virtual_machine_run_commands_begin_create_or_update(self, resource_grou "scriptUri": "str", "scriptUriManagedIdentity": {"clientId": "str", "objectId": "str"}, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, "type": "str", }, api_version="2024-11-01", @@ -105,7 +138,7 @@ def test_virtual_machine_run_commands_begin_update(self, resource_group): vm_name="str", run_command_name="str", run_command={ - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "instanceView": { @@ -141,7 +174,7 @@ def test_virtual_machine_run_commands_begin_update(self, resource_group): }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, }, api_version="2024-11-01", ).result() # call '.result()' to poll until service return final result @@ -161,28 +194,3 @@ def test_virtual_machine_run_commands_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_run_commands_get_by_virtual_machine(self, resource_group): - response = self.client.virtual_machine_run_commands.get_by_virtual_machine( - resource_group_name=resource_group.name, - vm_name="str", - run_command_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_run_commands_list_by_virtual_machine(self, resource_group): - response = self.client.virtual_machine_run_commands.list_by_virtual_machine( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py index a98c78cd9e3c..d59112620044 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_run_commands_operations_async.py @@ -42,6 +42,31 @@ async def test_virtual_machine_run_commands_get(self, resource_group): # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_run_commands_list_by_virtual_machine(self, resource_group): + response = self.client.virtual_machine_run_commands.list_by_virtual_machine( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_run_commands_get_by_virtual_machine(self, resource_group): + response = await self.client.virtual_machine_run_commands.get_by_virtual_machine( + resource_group_name=resource_group.name, + vm_name="str", + run_command_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_run_commands_begin_create_or_update(self, resource_group): @@ -52,7 +77,7 @@ async def test_virtual_machine_run_commands_begin_create_or_update(self, resourc run_command_name="str", run_command={ "location": "str", - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "id": "str", @@ -88,9 +113,17 @@ async def test_virtual_machine_run_commands_begin_create_or_update(self, resourc "scriptUri": "str", "scriptUriManagedIdentity": {"clientId": "str", "objectId": "str"}, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, "type": "str", }, api_version="2024-11-01", @@ -109,7 +142,7 @@ async def test_virtual_machine_run_commands_begin_update(self, resource_group): vm_name="str", run_command_name="str", run_command={ - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "instanceView": { @@ -145,7 +178,7 @@ async def test_virtual_machine_run_commands_begin_update(self, resource_group): }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, }, api_version="2024-11-01", ) @@ -168,28 +201,3 @@ async def test_virtual_machine_run_commands_begin_delete(self, resource_group): # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_run_commands_get_by_virtual_machine(self, resource_group): - response = await self.client.virtual_machine_run_commands.get_by_virtual_machine( - resource_group_name=resource_group.name, - vm_name="str", - run_command_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_run_commands_list_by_virtual_machine(self, resource_group): - response = self.client.virtual_machine_run_commands.list_by_virtual_machine( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py index 03e5d61f5908..4d3a58587e18 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations.py @@ -18,6 +18,31 @@ class TestComputeManagementVirtualMachineScaleSetExtensionsOperations(AzureMgmtR def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_extensions_list(self, resource_group): + response = self.client.virtual_machine_scale_set_extensions.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_extensions_get(self, resource_group): + response = self.client.virtual_machine_scale_set_extensions.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + vmss_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_scale_set_extensions_begin_create_or_update(self, resource_group): @@ -88,28 +113,3 @@ def test_virtual_machine_scale_set_extensions_begin_delete(self, resource_group) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_extensions_get(self, resource_group): - response = self.client.virtual_machine_scale_set_extensions.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - vmss_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_extensions_list(self, resource_group): - response = self.client.virtual_machine_scale_set_extensions.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py index 455263a801a7..da8856bcd638 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_extensions_operations_async.py @@ -19,6 +19,31 @@ class TestComputeManagementVirtualMachineScaleSetExtensionsOperationsAsync(Azure def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_extensions_list(self, resource_group): + response = self.client.virtual_machine_scale_set_extensions.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_extensions_get(self, resource_group): + response = await self.client.virtual_machine_scale_set_extensions.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + vmss_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_scale_set_extensions_begin_create_or_update(self, resource_group): @@ -95,28 +120,3 @@ async def test_virtual_machine_scale_set_extensions_begin_delete(self, resource_ # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_extensions_get(self, resource_group): - response = await self.client.virtual_machine_scale_set_extensions.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - vmss_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_extensions_list(self, resource_group): - response = self.client.virtual_machine_scale_set_extensions.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py index 05546f2e3698..739e00e8c77c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -20,8 +20,8 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_rolling_upgrades_begin_cancel(self, resource_group): - response = self.client.virtual_machine_scale_set_rolling_upgrades.begin_cancel( + def test_virtual_machine_scale_set_rolling_upgrades_begin_start_extension_upgrade(self, resource_group): + response = self.client.virtual_machine_scale_set_rolling_upgrades.begin_start_extension_upgrade( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -44,8 +44,8 @@ def test_virtual_machine_scale_set_rolling_upgrades_begin_start_os_upgrade(self, @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_rolling_upgrades_begin_start_extension_upgrade(self, resource_group): - response = self.client.virtual_machine_scale_set_rolling_upgrades.begin_start_extension_upgrade( + def test_virtual_machine_scale_set_rolling_upgrades_begin_cancel(self, resource_group): + response = self.client.virtual_machine_scale_set_rolling_upgrades.begin_cancel( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py index b750272734f1..b1f83bcb293a 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_rolling_upgrades_operations_async.py @@ -21,9 +21,9 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_rolling_upgrades_begin_cancel(self, resource_group): + async def test_virtual_machine_scale_set_rolling_upgrades_begin_start_extension_upgrade(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_rolling_upgrades.begin_cancel( + await self.client.virtual_machine_scale_set_rolling_upgrades.begin_start_extension_upgrade( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -49,9 +49,9 @@ async def test_virtual_machine_scale_set_rolling_upgrades_begin_start_os_upgrade @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_rolling_upgrades_begin_start_extension_upgrade(self, resource_group): + async def test_virtual_machine_scale_set_rolling_upgrades_begin_cancel(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_rolling_upgrades.begin_start_extension_upgrade( + await self.client.virtual_machine_scale_set_rolling_upgrades.begin_cancel( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py index 96bb5a01f81b..79bc0c5db2e4 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations.py @@ -18,6 +18,33 @@ class TestComputeManagementVirtualMachineScaleSetVMExtensionsOperations(AzureMgm def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vm_extensions_list(self, resource_group): + response = self.client.virtual_machine_scale_set_vm_extensions.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vm_extensions_get(self, resource_group): + response = self.client.virtual_machine_scale_set_vm_extensions.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + vm_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_scale_set_vm_extensions_begin_create_or_update(self, resource_group): @@ -113,30 +140,3 @@ def test_virtual_machine_scale_set_vm_extensions_begin_delete(self, resource_gro # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vm_extensions_get(self, resource_group): - response = self.client.virtual_machine_scale_set_vm_extensions.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - vm_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vm_extensions_list(self, resource_group): - response = self.client.virtual_machine_scale_set_vm_extensions.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py index 45821c887e5b..714184f060bd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_extensions_operations_async.py @@ -19,6 +19,33 @@ class TestComputeManagementVirtualMachineScaleSetVMExtensionsOperationsAsync(Azu def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vm_extensions_list(self, resource_group): + response = await self.client.virtual_machine_scale_set_vm_extensions.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vm_extensions_get(self, resource_group): + response = await self.client.virtual_machine_scale_set_vm_extensions.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + vm_extension_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_scale_set_vm_extensions_begin_create_or_update(self, resource_group): @@ -120,30 +147,3 @@ async def test_virtual_machine_scale_set_vm_extensions_begin_delete(self, resour # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vm_extensions_get(self, resource_group): - response = await self.client.virtual_machine_scale_set_vm_extensions.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - vm_extension_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vm_extensions_list(self, resource_group): - response = await self.client.virtual_machine_scale_set_vm_extensions.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py index 50cf9f96b1a7..e239d1deedea 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations.py @@ -18,6 +18,33 @@ class TestComputeManagementVirtualMachineScaleSetVMRunCommandsOperations(AzureMg def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vm_run_commands_list(self, resource_group): + response = self.client.virtual_machine_scale_set_vm_run_commands.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vm_run_commands_get(self, resource_group): + response = self.client.virtual_machine_scale_set_vm_run_commands.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + run_command_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update(self, resource_group): @@ -28,7 +55,7 @@ def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update(self, run_command_name="str", run_command={ "location": "str", - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "id": "str", @@ -64,9 +91,17 @@ def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update(self, "scriptUri": "str", "scriptUriManagedIdentity": {"clientId": "str", "objectId": "str"}, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, "type": "str", }, api_version="2024-11-01", @@ -84,7 +119,7 @@ def test_virtual_machine_scale_set_vm_run_commands_begin_update(self, resource_g instance_id="str", run_command_name="str", run_command={ - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "instanceView": { @@ -120,7 +155,7 @@ def test_virtual_machine_scale_set_vm_run_commands_begin_update(self, resource_g }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, }, api_version="2024-11-01", ).result() # call '.result()' to poll until service return final result @@ -141,30 +176,3 @@ def test_virtual_machine_scale_set_vm_run_commands_begin_delete(self, resource_g # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vm_run_commands_get(self, resource_group): - response = self.client.virtual_machine_scale_set_vm_run_commands.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - run_command_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vm_run_commands_list(self, resource_group): - response = self.client.virtual_machine_scale_set_vm_run_commands.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py index fe9943a7b934..1a4a123f955f 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vm_run_commands_operations_async.py @@ -19,6 +19,33 @@ class TestComputeManagementVirtualMachineScaleSetVMRunCommandsOperationsAsync(Az def setup_method(self, method): self.client = self.create_mgmt_client(ComputeManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vm_run_commands_list(self, resource_group): + response = self.client.virtual_machine_scale_set_vm_run_commands.list( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vm_run_commands_get(self, resource_group): + response = await self.client.virtual_machine_scale_set_vm_run_commands.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + run_command_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update(self, resource_group): @@ -30,7 +57,7 @@ async def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update( run_command_name="str", run_command={ "location": "str", - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "id": "str", @@ -66,9 +93,17 @@ async def test_virtual_machine_scale_set_vm_run_commands_begin_create_or_update( "scriptUri": "str", "scriptUriManagedIdentity": {"clientId": "str", "objectId": "str"}, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, "type": "str", }, api_version="2024-11-01", @@ -88,7 +123,7 @@ async def test_virtual_machine_scale_set_vm_run_commands_begin_update(self, reso instance_id="str", run_command_name="str", run_command={ - "asyncExecution": False, + "asyncExecution": bool, "errorBlobManagedIdentity": {"clientId": "str", "objectId": "str"}, "errorBlobUri": "str", "instanceView": { @@ -124,7 +159,7 @@ async def test_virtual_machine_scale_set_vm_run_commands_begin_update(self, reso }, "tags": {"str": "str"}, "timeoutInSeconds": 0, - "treatFailureAsDeploymentFailure": False, + "treatFailureAsDeploymentFailure": bool, }, api_version="2024-11-01", ) @@ -148,30 +183,3 @@ async def test_virtual_machine_scale_set_vm_run_commands_begin_delete(self, reso # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vm_run_commands_get(self, resource_group): - response = await self.client.virtual_machine_scale_set_vm_run_commands.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - run_command_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vm_run_commands_list(self, resource_group): - response = self.client.virtual_machine_scale_set_vm_run_commands.list( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py index 8c93f7e6640a..da3cb27f718c 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations.py @@ -20,52 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_reimage(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_reimage( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_reimage_all(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_reimage_all( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_approve_rolling_upgrade(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_approve_rolling_upgrade( + def test_virtual_machine_scale_set_vms_list(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.list( resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", + virtual_machine_scale_set_name="str", api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_deallocate(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_deallocate( + def test_virtual_machine_scale_set_vms_get(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.get( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @@ -355,6 +328,7 @@ def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "resilientVMDeletionStatus": "str", "resources": [ { + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -382,7 +356,6 @@ def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -391,6 +364,14 @@ def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -474,6 +455,14 @@ def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "writeAcceleratorEnabled": bool, }, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -502,59 +491,73 @@ def test_virtual_machine_scale_set_vms_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_get(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.get( + def test_virtual_machine_scale_set_vms_begin_approve_rolling_upgrade(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_approve_rolling_upgrade( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_get_instance_view(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.get_instance_view( + def test_virtual_machine_scale_set_vms_begin_attach_detach_data_disks(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_attach_detach_data_disks( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", + parameters={ + "dataDisksToAttach": [ + { + "diskId": "str", + "caching": "str", + "deleteOption": "str", + "diskEncryptionSet": {"id": "str"}, + "lun": 0, + "writeAcceleratorEnabled": bool, + } + ], + "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], + }, api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_list(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.list( + def test_virtual_machine_scale_set_vms_begin_deallocate(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_deallocate( resource_group_name=resource_group.name, - virtual_machine_scale_set_name="str", + vm_scale_set_name="str", + instance_id="str", api_version="2024-11-01", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_power_off(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_power_off( + def test_virtual_machine_scale_set_vms_get_instance_view(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.get_instance_view( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_restart( + def test_virtual_machine_scale_set_vms_begin_perform_maintenance(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_perform_maintenance( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -566,8 +569,8 @@ def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_start(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_start( + def test_virtual_machine_scale_set_vms_begin_power_off(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_power_off( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -592,21 +595,21 @@ def test_virtual_machine_scale_set_vms_begin_redeploy(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.retrieve_boot_diagnostics_data( + def test_virtual_machine_scale_set_vms_begin_reimage(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_reimage( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_perform_maintenance(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_perform_maintenance( + def test_virtual_machine_scale_set_vms_begin_reimage_all(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_reimage_all( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -618,39 +621,26 @@ def test_virtual_machine_scale_set_vms_begin_perform_maintenance(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_simulate_eviction(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.simulate_eviction( + def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_restart( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_set_vms_begin_attach_detach_data_disks(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.begin_attach_detach_data_disks( + def test_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.retrieve_boot_diagnostics_data( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", - parameters={ - "dataDisksToAttach": [ - { - "diskId": "str", - "caching": "str", - "deleteOption": "str", - "diskEncryptionSet": {"id": "str"}, - "lun": 0, - "writeAcceleratorEnabled": bool, - } - ], - "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], - }, api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @@ -668,3 +658,29 @@ def test_virtual_machine_scale_set_vms_begin_run_command(self, resource_group): # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vms_simulate_eviction(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.simulate_eviction( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_set_vms_begin_start(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.begin_start( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py index 855c34b4315f..68b2d4a768dd 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_set_vms_operations_async.py @@ -21,60 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_reimage(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_set_vms.begin_reimage( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_reimage_all(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_set_vms.begin_reimage_all( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_approve_rolling_upgrade(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_set_vms.begin_approve_rolling_upgrade( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - + async def test_virtual_machine_scale_set_vms_list(self, resource_group): + response = self.client.virtual_machine_scale_set_vms.list( + resource_group_name=resource_group.name, + virtual_machine_scale_set_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_deallocate(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_set_vms.begin_deallocate( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_virtual_machine_scale_set_vms_get(self, resource_group): + response = await self.client.virtual_machine_scale_set_vms.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) # please add some check logic here by yourself # ... @@ -365,6 +330,7 @@ async def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "resilientVMDeletionStatus": "str", "resources": [ { + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -392,7 +358,6 @@ async def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -401,6 +366,14 @@ async def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -487,6 +460,14 @@ async def test_virtual_machine_scale_set_vms_begin_update(self, resource_group): "writeAcceleratorEnabled": bool, }, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -518,13 +499,58 @@ async def test_virtual_machine_scale_set_vms_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_get(self, resource_group): - response = await self.client.virtual_machine_scale_set_vms.get( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - api_version="2024-11-01", - ) + async def test_virtual_machine_scale_set_vms_begin_approve_rolling_upgrade(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_set_vms.begin_approve_rolling_upgrade( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vms_begin_attach_detach_data_disks(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_set_vms.begin_attach_detach_data_disks( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + parameters={ + "dataDisksToAttach": [ + { + "diskId": "str", + "caching": "str", + "deleteOption": "str", + "diskEncryptionSet": {"id": "str"}, + "lun": 0, + "writeAcceleratorEnabled": bool, + } + ], + "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vms_begin_deallocate(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_set_vms.begin_deallocate( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -544,13 +570,16 @@ async def test_virtual_machine_scale_set_vms_get_instance_view(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_list(self, resource_group): - response = self.client.virtual_machine_scale_set_vms.list( - resource_group_name=resource_group.name, - virtual_machine_scale_set_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] + async def test_virtual_machine_scale_set_vms_begin_perform_maintenance(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_set_vms.begin_perform_maintenance( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -571,9 +600,9 @@ async def test_virtual_machine_scale_set_vms_begin_power_off(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group): + async def test_virtual_machine_scale_set_vms_begin_redeploy(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_vms.begin_restart( + await self.client.virtual_machine_scale_set_vms.begin_redeploy( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -586,9 +615,9 @@ async def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_start(self, resource_group): + async def test_virtual_machine_scale_set_vms_begin_reimage(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_vms.begin_start( + await self.client.virtual_machine_scale_set_vms.begin_reimage( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -601,9 +630,24 @@ async def test_virtual_machine_scale_set_vms_begin_start(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_redeploy(self, resource_group): + async def test_virtual_machine_scale_set_vms_begin_reimage_all(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_vms.begin_redeploy( + await self.client.virtual_machine_scale_set_vms.begin_reimage_all( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + instance_id="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_set_vms_begin_restart(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_set_vms.begin_restart( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", @@ -629,12 +673,13 @@ async def test_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data(self @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_perform_maintenance(self, resource_group): + async def test_virtual_machine_scale_set_vms_begin_run_command(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_vms.begin_perform_maintenance( + await self.client.virtual_machine_scale_set_vms.begin_run_command( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", + parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, api_version="2024-11-01", ) ).result() # call '.result()' to poll until service return final result @@ -657,41 +702,12 @@ async def test_virtual_machine_scale_set_vms_simulate_eviction(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_attach_detach_data_disks(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_set_vms.begin_attach_detach_data_disks( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - instance_id="str", - parameters={ - "dataDisksToAttach": [ - { - "diskId": "str", - "caching": "str", - "deleteOption": "str", - "diskEncryptionSet": {"id": "str"}, - "lun": 0, - "writeAcceleratorEnabled": bool, - } - ], - "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], - }, - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_set_vms_begin_run_command(self, resource_group): + async def test_virtual_machine_scale_set_vms_begin_start(self, resource_group): response = await ( - await self.client.virtual_machine_scale_set_vms.begin_run_command( + await self.client.virtual_machine_scale_set_vms.begin_start( resource_group_name=resource_group.name, vm_scale_set_name="str", instance_id="str", - parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, api_version="2024-11-01", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py index 2e36cf50457c..6276611575a2 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations.py @@ -29,6 +29,39 @@ def test_virtual_machine_scale_sets_list_by_location(self, resource_group): # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_sets_list_all(self, resource_group): + response = self.client.virtual_machine_scale_sets.list_all( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_sets_list(self, resource_group): + response = self.client.virtual_machine_scale_sets.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_sets_get(self, resource_group): + response = self.client.virtual_machine_scale_sets.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_group): @@ -41,7 +74,7 @@ def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_group) "automaticRepairsPolicy": {"enabled": bool, "gracePeriod": "str", "repairAction": "str"}, "constrainedMaximumCapacity": bool, "doNotRunExtensionsOnOverprovisionedVMs": bool, - "etag": "str", + "eTag": "str", "extendedLocation": {"name": "str", "type": "str"}, "hostGroup": {"id": "str"}, "id": "str", @@ -78,6 +111,14 @@ def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_group) "sku": {"capacity": 0, "name": "str", "tier": "str"}, "skuProfile": {"allocationStrategy": "str", "vmSizes": [{"name": "str", "rank": 0}]}, "spotRestorePolicy": {"enabled": bool, "restoreTimeout": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -580,11 +621,24 @@ def test_virtual_machine_scale_sets_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_get(self, resource_group): - response = self.client.virtual_machine_scale_sets.get( + def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_approve_rolling_upgrade( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machine_scale_sets_convert_to_single_placement_group(self, resource_group): + response = self.client.virtual_machine_scale_sets.convert_to_single_placement_group( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + parameters={"activePlacementGroupId": "str"}, + api_version="2024-11-01", ) # please add some check logic here by yourself @@ -617,10 +671,11 @@ def test_virtual_machine_scale_sets_begin_delete_instances(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_get_instance_view(self, resource_group): - response = self.client.virtual_machine_scale_sets.get_instance_view( + def test_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk(self, resource_group): + response = self.client.virtual_machine_scale_sets.force_recovery_service_fabric_platform_update_domain_walk( resource_group_name=resource_group.name, vm_scale_set_name="str", + platform_update_domain=0, api_version="2024-11-01", ) @@ -629,34 +684,26 @@ def test_virtual_machine_scale_sets_get_instance_view(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_list(self, resource_group): - response = self.client.virtual_machine_scale_sets.list( + def test_virtual_machine_scale_sets_get_instance_view(self, resource_group): + response = self.client.virtual_machine_scale_sets.get_instance_view( resource_group_name=resource_group.name, + vm_scale_set_name="str", api_version="2024-11-01", ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_sets_list_all(self, resource_group): - response = self.client.virtual_machine_scale_sets.list_all( - api_version="2024-11-01", - ) - result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_list_skus(self, resource_group): - response = self.client.virtual_machine_scale_sets.list_skus( + def test_virtual_machine_scale_sets_begin_update_instances(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_update_instances( resource_group_name=resource_group.name, vm_scale_set_name="str", + vm_instance_i_ds={"instanceIds": ["str"]}, api_version="2024-11-01", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -674,20 +721,8 @@ def test_virtual_machine_scale_sets_get_os_upgrade_history(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_power_off(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_power_off( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_restart(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_restart( + def test_virtual_machine_scale_sets_begin_perform_maintenance(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_perform_maintenance( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -698,8 +733,8 @@ def test_virtual_machine_scale_sets_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_start(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_start( + def test_virtual_machine_scale_sets_begin_power_off(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_power_off( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -732,31 +767,6 @@ def test_virtual_machine_scale_sets_begin_redeploy(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_perform_maintenance(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_perform_maintenance( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_update_instances(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_update_instances( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - vm_instance_i_ds={"instanceIds": ["str"]}, - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_virtual_machine_scale_sets_begin_reimage(self, resource_group): @@ -783,8 +793,8 @@ def test_virtual_machine_scale_sets_begin_reimage_all(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_approve_rolling_upgrade( + def test_virtual_machine_scale_sets_begin_restart(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_restart( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -795,37 +805,35 @@ def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, resource @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk(self, resource_group): - response = self.client.virtual_machine_scale_sets.force_recovery_service_fabric_platform_update_domain_walk( + def test_virtual_machine_scale_sets_begin_set_orchestration_service_state(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_set_orchestration_service_state( resource_group_name=resource_group.name, vm_scale_set_name="str", - platform_update_domain=0, + parameters={"action": "str", "serviceName": "str"}, api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_convert_to_single_placement_group(self, resource_group): - response = self.client.virtual_machine_scale_sets.convert_to_single_placement_group( + def test_virtual_machine_scale_sets_list_skus(self, resource_group): + response = self.client.virtual_machine_scale_sets.list_skus( resource_group_name=resource_group.name, vm_scale_set_name="str", - parameters={"activePlacementGroupId": "str"}, api_version="2024-11-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machine_scale_sets_begin_set_orchestration_service_state(self, resource_group): - response = self.client.virtual_machine_scale_sets.begin_set_orchestration_service_state( + def test_virtual_machine_scale_sets_begin_start(self, resource_group): + response = self.client.virtual_machine_scale_sets.begin_start( resource_group_name=resource_group.name, vm_scale_set_name="str", - parameters={"action": "str", "serviceName": "str"}, api_version="2024-11-01", ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py index 3dba0dcf6a01..7ff8905f1c73 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machine_scale_sets_operations_async.py @@ -30,6 +30,39 @@ async def test_virtual_machine_scale_sets_list_by_location(self, resource_group) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_sets_list_all(self, resource_group): + response = self.client.virtual_machine_scale_sets.list_all( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_sets_list(self, resource_group): + response = self.client.virtual_machine_scale_sets.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_sets_get(self, resource_group): + response = await self.client.virtual_machine_scale_sets.get( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + api_version="2024-11-01", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_group): @@ -43,7 +76,7 @@ async def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_ "automaticRepairsPolicy": {"enabled": bool, "gracePeriod": "str", "repairAction": "str"}, "constrainedMaximumCapacity": bool, "doNotRunExtensionsOnOverprovisionedVMs": bool, - "etag": "str", + "eTag": "str", "extendedLocation": {"name": "str", "type": "str"}, "hostGroup": {"id": "str"}, "id": "str", @@ -80,6 +113,14 @@ async def test_virtual_machine_scale_sets_begin_create_or_update(self, resource_ "sku": {"capacity": 0, "name": "str", "tier": "str"}, "skuProfile": {"allocationStrategy": "str", "vmSizes": [{"name": "str", "rank": 0}]}, "spotRestorePolicy": {"enabled": bool, "restoreTimeout": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -593,10 +634,25 @@ async def test_virtual_machine_scale_sets_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_get(self, resource_group): - response = await self.client.virtual_machine_scale_sets.get( + async def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_sets.begin_approve_rolling_upgrade( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machine_scale_sets_convert_to_single_placement_group(self, resource_group): + response = await self.client.virtual_machine_scale_sets.convert_to_single_placement_group( resource_group_name=resource_group.name, vm_scale_set_name="str", + parameters={"activePlacementGroupId": "str"}, api_version="2024-11-01", ) @@ -634,11 +690,16 @@ async def test_virtual_machine_scale_sets_begin_delete_instances(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_get_instance_view(self, resource_group): - response = await self.client.virtual_machine_scale_sets.get_instance_view( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", + async def test_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk( + self, resource_group + ): + response = ( + await self.client.virtual_machine_scale_sets.force_recovery_service_fabric_platform_update_domain_walk( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + platform_update_domain=0, + api_version="2024-11-01", + ) ) # please add some check logic here by yourself @@ -646,34 +707,28 @@ async def test_virtual_machine_scale_sets_get_instance_view(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_list(self, resource_group): - response = self.client.virtual_machine_scale_sets.list( + async def test_virtual_machine_scale_sets_get_instance_view(self, resource_group): + response = await self.client.virtual_machine_scale_sets.get_instance_view( resource_group_name=resource_group.name, + vm_scale_set_name="str", api_version="2024-11-01", ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_list_all(self, resource_group): - response = self.client.virtual_machine_scale_sets.list_all( - api_version="2024-11-01", - ) - result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_list_skus(self, resource_group): - response = self.client.virtual_machine_scale_sets.list_skus( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ) - result = [r async for r in response] + async def test_virtual_machine_scale_sets_begin_update_instances(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_sets.begin_update_instances( + resource_group_name=resource_group.name, + vm_scale_set_name="str", + vm_instance_i_ds={"instanceIds": ["str"]}, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -691,23 +746,9 @@ async def test_virtual_machine_scale_sets_get_os_upgrade_history(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_power_off(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_sets.begin_power_off( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_restart(self, resource_group): + async def test_virtual_machine_scale_sets_begin_perform_maintenance(self, resource_group): response = await ( - await self.client.virtual_machine_scale_sets.begin_restart( + await self.client.virtual_machine_scale_sets.begin_perform_maintenance( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -719,9 +760,9 @@ async def test_virtual_machine_scale_sets_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_start(self, resource_group): + async def test_virtual_machine_scale_sets_begin_power_off(self, resource_group): response = await ( - await self.client.virtual_machine_scale_sets.begin_start( + await self.client.virtual_machine_scale_sets.begin_power_off( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -759,35 +800,6 @@ async def test_virtual_machine_scale_sets_begin_redeploy(self, resource_group): # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_perform_maintenance(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_sets.begin_perform_maintenance( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_update_instances(self, resource_group): - response = await ( - await self.client.virtual_machine_scale_sets.begin_update_instances( - resource_group_name=resource_group.name, - vm_scale_set_name="str", - vm_instance_i_ds={"instanceIds": ["str"]}, - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_virtual_machine_scale_sets_begin_reimage(self, resource_group): @@ -818,9 +830,9 @@ async def test_virtual_machine_scale_sets_begin_reimage_all(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, resource_group): + async def test_virtual_machine_scale_sets_begin_restart(self, resource_group): response = await ( - await self.client.virtual_machine_scale_sets.begin_approve_rolling_upgrade( + await self.client.virtual_machine_scale_sets.begin_restart( resource_group_name=resource_group.name, vm_scale_set_name="str", api_version="2024-11-01", @@ -832,42 +844,38 @@ async def test_virtual_machine_scale_sets_begin_approve_rolling_upgrade(self, re @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk( - self, resource_group - ): - response = ( - await self.client.virtual_machine_scale_sets.force_recovery_service_fabric_platform_update_domain_walk( + async def test_virtual_machine_scale_sets_begin_set_orchestration_service_state(self, resource_group): + response = await ( + await self.client.virtual_machine_scale_sets.begin_set_orchestration_service_state( resource_group_name=resource_group.name, vm_scale_set_name="str", - platform_update_domain=0, + parameters={"action": "str", "serviceName": "str"}, api_version="2024-11-01", ) - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_convert_to_single_placement_group(self, resource_group): - response = await self.client.virtual_machine_scale_sets.convert_to_single_placement_group( + async def test_virtual_machine_scale_sets_list_skus(self, resource_group): + response = self.client.virtual_machine_scale_sets.list_skus( resource_group_name=resource_group.name, vm_scale_set_name="str", - parameters={"activePlacementGroupId": "str"}, api_version="2024-11-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machine_scale_sets_begin_set_orchestration_service_state(self, resource_group): + async def test_virtual_machine_scale_sets_begin_start(self, resource_group): response = await ( - await self.client.virtual_machine_scale_sets.begin_set_orchestration_service_state( + await self.client.virtual_machine_scale_sets.begin_start( resource_group_name=resource_group.name, vm_scale_set_name="str", - parameters={"action": "str", "serviceName": "str"}, api_version="2024-11-01", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py index 39983f32d436..6b2da573845d 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations.py @@ -31,13 +31,33 @@ def test_virtual_machines_list_by_location(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_capture(self, resource_group): - response = self.client.virtual_machines.begin_capture( + def test_virtual_machines_list_all(self, resource_group): + response = self.client.virtual_machines.list_all( + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machines_list(self, resource_group): + response = self.client.virtual_machines.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machines_get(self, resource_group): + response = self.client.virtual_machines.get( resource_group_name=resource_group.name, vm_name="str", - parameters={"destinationContainerName": "str", "overwriteVhds": bool, "vhdPrefix": "str"}, api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @@ -67,7 +87,7 @@ def test_virtual_machines_begin_create_or_update(self, resource_group): "billingProfile": {"maxPrice": 0.0}, "capacityReservation": {"capacityReservationGroup": {"id": "str"}}, "diagnosticsProfile": {"bootDiagnostics": {"enabled": bool, "storageUri": "str"}}, - "etag": "str", + "eTag": "str", "evictionPolicy": "str", "extendedLocation": {"name": "str", "type": "str"}, "extensionsTimeBudget": "str", @@ -352,6 +372,7 @@ def test_virtual_machines_begin_create_or_update(self, resource_group): "proximityPlacementGroup": {"id": "str"}, "resources": [ { + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -379,7 +400,6 @@ def test_virtual_machines_begin_create_or_update(self, resource_group): "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -388,6 +408,14 @@ def test_virtual_machines_begin_create_or_update(self, resource_group): "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -479,6 +507,14 @@ def test_virtual_machines_begin_create_or_update(self, resource_group): "writeAcceleratorEnabled": bool, }, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -907,24 +943,50 @@ def test_virtual_machines_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_get(self, resource_group): - response = self.client.virtual_machines.get( + def test_virtual_machines_begin_assess_patches(self, resource_group): + response = self.client.virtual_machines.begin_assess_patches( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_instance_view(self, resource_group): - response = self.client.virtual_machines.instance_view( + def test_virtual_machines_begin_attach_detach_data_disks(self, resource_group): + response = self.client.virtual_machines.begin_attach_detach_data_disks( resource_group_name=resource_group.name, vm_name="str", + parameters={ + "dataDisksToAttach": [ + { + "diskId": "str", + "caching": "str", + "deleteOption": "str", + "diskEncryptionSet": {"id": "str"}, + "lun": 0, + "writeAcceleratorEnabled": bool, + } + ], + "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], + }, api_version="2024-11-01", - ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_machines_begin_capture(self, resource_group): + response = self.client.virtual_machines.begin_capture( + resource_group_name=resource_group.name, + vm_name="str", + parameters={"destinationContainerName": "str", "overwriteVhds": bool, "vhdPrefix": "str"}, + api_version="2024-11-01", + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -967,41 +1029,49 @@ def test_virtual_machines_generalize(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_list(self, resource_group): - response = self.client.virtual_machines.list( + def test_virtual_machines_begin_install_patches(self, resource_group): + response = self.client.virtual_machines.begin_install_patches( resource_group_name=resource_group.name, + vm_name="str", + install_patches_input={ + "rebootSetting": "str", + "linuxParameters": { + "classificationsToInclude": ["str"], + "maintenanceRunId": "str", + "packageNameMasksToExclude": ["str"], + "packageNameMasksToInclude": ["str"], + }, + "maximumDuration": "1 day, 0:00:00", + "windowsParameters": { + "classificationsToInclude": ["str"], + "excludeKbsRequiringReboot": bool, + "kbNumbersToExclude": ["str"], + "kbNumbersToInclude": ["str"], + "maxPatchPublishDate": "2020-02-20 00:00:00", + }, + }, api_version="2024-11-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... + ).result() # call '.result()' to poll until service return final result - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machines_list_all(self, resource_group): - response = self.client.virtual_machines.list_all( - api_version="2024-11-01", - ) - result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_list_available_sizes(self, resource_group): - response = self.client.virtual_machines.list_available_sizes( + def test_virtual_machines_instance_view(self, resource_group): + response = self.client.virtual_machines.instance_view( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_power_off(self, resource_group): - response = self.client.virtual_machines.begin_power_off( + def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_group): + response = self.client.virtual_machines.begin_migrate_to_vm_scale_set( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1012,8 +1082,8 @@ def test_virtual_machines_begin_power_off(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_reapply(self, resource_group): - response = self.client.virtual_machines.begin_reapply( + def test_virtual_machines_begin_perform_maintenance(self, resource_group): + response = self.client.virtual_machines.begin_perform_maintenance( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1024,8 +1094,8 @@ def test_virtual_machines_begin_reapply(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_restart(self, resource_group): - response = self.client.virtual_machines.begin_restart( + def test_virtual_machines_begin_power_off(self, resource_group): + response = self.client.virtual_machines.begin_power_off( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1036,8 +1106,8 @@ def test_virtual_machines_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_start(self, resource_group): - response = self.client.virtual_machines.begin_start( + def test_virtual_machines_begin_reapply(self, resource_group): + response = self.client.virtual_machines.begin_reapply( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1072,20 +1142,8 @@ def test_virtual_machines_begin_reimage(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_retrieve_boot_diagnostics_data(self, resource_group): - response = self.client.virtual_machines.retrieve_boot_diagnostics_data( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machines_begin_perform_maintenance(self, resource_group): - response = self.client.virtual_machines.begin_perform_maintenance( + def test_virtual_machines_begin_restart(self, resource_group): + response = self.client.virtual_machines.begin_restart( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1096,8 +1154,8 @@ def test_virtual_machines_begin_perform_maintenance(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_simulate_eviction(self, resource_group): - response = self.client.virtual_machines.simulate_eviction( + def test_virtual_machines_retrieve_boot_diagnostics_data(self, resource_group): + response = self.client.virtual_machines.retrieve_boot_diagnostics_data( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1108,39 +1166,11 @@ def test_virtual_machines_simulate_eviction(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_assess_patches(self, resource_group): - response = self.client.virtual_machines.begin_assess_patches( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_virtual_machines_begin_install_patches(self, resource_group): - response = self.client.virtual_machines.begin_install_patches( + def test_virtual_machines_begin_run_command(self, resource_group): + response = self.client.virtual_machines.begin_run_command( resource_group_name=resource_group.name, vm_name="str", - install_patches_input={ - "rebootSetting": "str", - "linuxParameters": { - "classificationsToInclude": ["str"], - "maintenanceRunId": "str", - "packageNameMasksToExclude": ["str"], - "packageNameMasksToInclude": ["str"], - }, - "maximumDuration": "str", - "windowsParameters": { - "classificationsToInclude": ["str"], - "excludeKbsRequiringReboot": bool, - "kbNumbersToExclude": ["str"], - "kbNumbersToInclude": ["str"], - "maxPatchPublishDate": "2020-02-20 00:00:00", - }, - }, + parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, api_version="2024-11-01", ).result() # call '.result()' to poll until service return final result @@ -1149,33 +1179,20 @@ def test_virtual_machines_begin_install_patches(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_attach_detach_data_disks(self, resource_group): - response = self.client.virtual_machines.begin_attach_detach_data_disks( + def test_virtual_machines_simulate_eviction(self, resource_group): + response = self.client.virtual_machines.simulate_eviction( resource_group_name=resource_group.name, vm_name="str", - parameters={ - "dataDisksToAttach": [ - { - "diskId": "str", - "caching": "str", - "deleteOption": "str", - "diskEncryptionSet": {"id": "str"}, - "lun": 0, - "writeAcceleratorEnabled": bool, - } - ], - "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], - }, api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_group): - response = self.client.virtual_machines.begin_migrate_to_vm_scale_set( + def test_virtual_machines_begin_start(self, resource_group): + response = self.client.virtual_machines.begin_start( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1186,13 +1203,12 @@ def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_machines_begin_run_command(self, resource_group): - response = self.client.virtual_machines.begin_run_command( + def test_virtual_machines_list_available_sizes(self, resource_group): + response = self.client.virtual_machines.list_available_sizes( resource_group_name=resource_group.name, vm_name="str", - parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, api_version="2024-11-01", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py index 702fca5ceab9..dd9ece74f44e 100644 --- a/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py +++ b/sdk/compute/azure-mgmt-compute/generated_tests/test_compute_management_virtual_machines_operations_async.py @@ -32,15 +32,33 @@ async def test_virtual_machines_list_by_location(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_capture(self, resource_group): - response = await ( - await self.client.virtual_machines.begin_capture( - resource_group_name=resource_group.name, - vm_name="str", - parameters={"destinationContainerName": "str", "overwriteVhds": bool, "vhdPrefix": "str"}, - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_virtual_machines_list_all(self, resource_group): + response = self.client.virtual_machines.list_all( + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machines_list(self, resource_group): + response = self.client.virtual_machines.list( + resource_group_name=resource_group.name, + api_version="2024-11-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machines_get(self, resource_group): + response = await self.client.virtual_machines.get( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) # please add some check logic here by yourself # ... @@ -71,7 +89,7 @@ async def test_virtual_machines_begin_create_or_update(self, resource_group): "billingProfile": {"maxPrice": 0.0}, "capacityReservation": {"capacityReservationGroup": {"id": "str"}}, "diagnosticsProfile": {"bootDiagnostics": {"enabled": bool, "storageUri": "str"}}, - "etag": "str", + "eTag": "str", "evictionPolicy": "str", "extendedLocation": {"name": "str", "type": "str"}, "extensionsTimeBudget": "str", @@ -356,6 +374,7 @@ async def test_virtual_machines_begin_create_or_update(self, resource_group): "proximityPlacementGroup": {"id": "str"}, "resources": [ { + "location": "str", "autoUpgradeMinorVersion": bool, "enableAutomaticUpgrade": bool, "forceUpdateTag": "str", @@ -383,7 +402,6 @@ async def test_virtual_machines_begin_create_or_update(self, resource_group): "type": "str", "typeHandlerVersion": "str", }, - "location": "str", "name": "str", "protectedSettings": {}, "protectedSettingsFromKeyVault": {"secretUrl": "str", "sourceVault": {"id": "str"}}, @@ -392,6 +410,14 @@ async def test_virtual_machines_begin_create_or_update(self, resource_group): "publisher": "str", "settings": {}, "suppressFailures": bool, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", "typeHandlerVersion": "str", @@ -486,6 +512,14 @@ async def test_virtual_machines_begin_create_or_update(self, resource_group): "writeAcceleratorEnabled": bool, }, }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "timeCreated": "2020-02-20 00:00:00", "type": "str", @@ -922,24 +956,56 @@ async def test_virtual_machines_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_get(self, resource_group): - response = await self.client.virtual_machines.get( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) + async def test_virtual_machines_begin_assess_patches(self, resource_group): + response = await ( + await self.client.virtual_machines.begin_assess_patches( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_instance_view(self, resource_group): - response = await self.client.virtual_machines.instance_view( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) + async def test_virtual_machines_begin_attach_detach_data_disks(self, resource_group): + response = await ( + await self.client.virtual_machines.begin_attach_detach_data_disks( + resource_group_name=resource_group.name, + vm_name="str", + parameters={ + "dataDisksToAttach": [ + { + "diskId": "str", + "caching": "str", + "deleteOption": "str", + "diskEncryptionSet": {"id": "str"}, + "lun": 0, + "writeAcceleratorEnabled": bool, + } + ], + "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_machines_begin_capture(self, resource_group): + response = await ( + await self.client.virtual_machines.begin_capture( + resource_group_name=resource_group.name, + vm_name="str", + parameters={"destinationContainerName": "str", "overwriteVhds": bool, "vhdPrefix": "str"}, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -986,42 +1052,52 @@ async def test_virtual_machines_generalize(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_list(self, resource_group): - response = self.client.virtual_machines.list( - resource_group_name=resource_group.name, - api_version="2024-11-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... + async def test_virtual_machines_begin_install_patches(self, resource_group): + response = await ( + await self.client.virtual_machines.begin_install_patches( + resource_group_name=resource_group.name, + vm_name="str", + install_patches_input={ + "rebootSetting": "str", + "linuxParameters": { + "classificationsToInclude": ["str"], + "maintenanceRunId": "str", + "packageNameMasksToExclude": ["str"], + "packageNameMasksToInclude": ["str"], + }, + "maximumDuration": "1 day, 0:00:00", + "windowsParameters": { + "classificationsToInclude": ["str"], + "excludeKbsRequiringReboot": bool, + "kbNumbersToExclude": ["str"], + "kbNumbersToInclude": ["str"], + "maxPatchPublishDate": "2020-02-20 00:00:00", + }, + }, + api_version="2024-11-01", + ) + ).result() # call '.result()' to poll until service return final result - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machines_list_all(self, resource_group): - response = self.client.virtual_machines.list_all( - api_version="2024-11-01", - ) - result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_list_available_sizes(self, resource_group): - response = self.client.virtual_machines.list_available_sizes( + async def test_virtual_machines_instance_view(self, resource_group): + response = await self.client.virtual_machines.instance_view( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_power_off(self, resource_group): + async def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_group): response = await ( - await self.client.virtual_machines.begin_power_off( + await self.client.virtual_machines.begin_migrate_to_vm_scale_set( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1033,9 +1109,9 @@ async def test_virtual_machines_begin_power_off(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_reapply(self, resource_group): + async def test_virtual_machines_begin_perform_maintenance(self, resource_group): response = await ( - await self.client.virtual_machines.begin_reapply( + await self.client.virtual_machines.begin_perform_maintenance( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1047,9 +1123,9 @@ async def test_virtual_machines_begin_reapply(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_restart(self, resource_group): + async def test_virtual_machines_begin_power_off(self, resource_group): response = await ( - await self.client.virtual_machines.begin_restart( + await self.client.virtual_machines.begin_power_off( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1061,9 +1137,9 @@ async def test_virtual_machines_begin_restart(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_start(self, resource_group): + async def test_virtual_machines_begin_reapply(self, resource_group): response = await ( - await self.client.virtual_machines.begin_start( + await self.client.virtual_machines.begin_reapply( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1103,21 +1179,9 @@ async def test_virtual_machines_begin_reimage(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_retrieve_boot_diagnostics_data(self, resource_group): - response = await self.client.virtual_machines.retrieve_boot_diagnostics_data( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machines_begin_perform_maintenance(self, resource_group): + async def test_virtual_machines_begin_restart(self, resource_group): response = await ( - await self.client.virtual_machines.begin_perform_maintenance( + await self.client.virtual_machines.begin_restart( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1129,8 +1193,8 @@ async def test_virtual_machines_begin_perform_maintenance(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_simulate_eviction(self, resource_group): - response = await self.client.virtual_machines.simulate_eviction( + async def test_virtual_machines_retrieve_boot_diagnostics_data(self, resource_group): + response = await self.client.virtual_machines.retrieve_boot_diagnostics_data( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1141,42 +1205,12 @@ async def test_virtual_machines_simulate_eviction(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_assess_patches(self, resource_group): - response = await ( - await self.client.virtual_machines.begin_assess_patches( - resource_group_name=resource_group.name, - vm_name="str", - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_virtual_machines_begin_install_patches(self, resource_group): + async def test_virtual_machines_begin_run_command(self, resource_group): response = await ( - await self.client.virtual_machines.begin_install_patches( + await self.client.virtual_machines.begin_run_command( resource_group_name=resource_group.name, vm_name="str", - install_patches_input={ - "rebootSetting": "str", - "linuxParameters": { - "classificationsToInclude": ["str"], - "maintenanceRunId": "str", - "packageNameMasksToExclude": ["str"], - "packageNameMasksToInclude": ["str"], - }, - "maximumDuration": "str", - "windowsParameters": { - "classificationsToInclude": ["str"], - "excludeKbsRequiringReboot": bool, - "kbNumbersToExclude": ["str"], - "kbNumbersToInclude": ["str"], - "maxPatchPublishDate": "2020-02-20 00:00:00", - }, - }, + parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, api_version="2024-11-01", ) ).result() # call '.result()' to poll until service return final result @@ -1186,36 +1220,21 @@ async def test_virtual_machines_begin_install_patches(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_attach_detach_data_disks(self, resource_group): - response = await ( - await self.client.virtual_machines.begin_attach_detach_data_disks( - resource_group_name=resource_group.name, - vm_name="str", - parameters={ - "dataDisksToAttach": [ - { - "diskId": "str", - "caching": "str", - "deleteOption": "str", - "diskEncryptionSet": {"id": "str"}, - "lun": 0, - "writeAcceleratorEnabled": bool, - } - ], - "dataDisksToDetach": [{"diskId": "str", "detachOption": "str"}], - }, - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_virtual_machines_simulate_eviction(self, resource_group): + response = await self.client.virtual_machines.simulate_eviction( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_group): + async def test_virtual_machines_begin_start(self, resource_group): response = await ( - await self.client.virtual_machines.begin_migrate_to_vm_scale_set( + await self.client.virtual_machines.begin_start( resource_group_name=resource_group.name, vm_name="str", api_version="2024-11-01", @@ -1227,15 +1246,12 @@ async def test_virtual_machines_begin_migrate_to_vm_scale_set(self, resource_gro @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_machines_begin_run_command(self, resource_group): - response = await ( - await self.client.virtual_machines.begin_run_command( - resource_group_name=resource_group.name, - vm_name="str", - parameters={"commandId": "str", "parameters": [{"name": "str", "value": "str"}], "script": ["str"]}, - api_version="2024-11-01", - ) - ).result() # call '.result()' to poll until service return final result - + async def test_virtual_machines_list_available_sizes(self, resource_group): + response = self.client.virtual_machines.list_available_sizes( + resource_group_name=resource_group.name, + vm_name="str", + api_version="2024-11-01", + ) + result = [r async for r in response] # please add some check logic here by yourself # ...