diff --git a/sdk/compute/azure-mgmt-compute/_meta.json b/sdk/compute/azure-mgmt-compute/_meta.json index 661176531ea0..b7b6b86fc63a 100644 --- a/sdk/compute/azure-mgmt-compute/_meta.json +++ b/sdk/compute/azure-mgmt-compute/_meta.json @@ -1,12 +1,12 @@ { - "commit": "898ea5c3fac1ef8041ef6339ae00072058b06285", + "commit": "38c9c56602b0a03b0828e3269c402a5018347216", "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/v2016_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py index cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py index 719ce120eb3f..8f740f003dd2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_compute_management_client.py @@ -42,28 +42,6 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar galleries: GalleriesOperations operations :vartype galleries: azure.mgmt.compute.v2023_07_03.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2023_07_03.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2023_07_03.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2023_07_03.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2023_07_03.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2023_07_03.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: azure.mgmt.compute.v2023_07_03.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2023_07_03.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2023_07_03.operations.SharedGalleryImageVersionsOperations :ivar community_galleries: CommunityGalleriesOperations operations :vartype community_galleries: azure.mgmt.compute.v2023_07_03.operations.CommunityGalleriesOperations @@ -73,10 +51,31 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations :vartype community_gallery_image_versions: azure.mgmt.compute.v2023_07_03.operations.CommunityGalleryImageVersionsOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: azure.mgmt.compute.v2023_07_03.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: + azure.mgmt.compute.v2023_07_03.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.v2023_07_03.operations.SharedGalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: + azure.mgmt.compute.v2023_07_03.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.v2023_07_03.operations.GalleryApplicationVersionsOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.v2023_07_03.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: + azure.mgmt.compute.v2023_07_03.operations.GalleryImageVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: + azure.mgmt.compute.v2023_07_03.operations.GallerySharingProfileOperations :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 @@ -124,37 +123,37 @@ def __init__( self.galleries = GalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_images = GalleryImagesOperations( + self.community_galleries = CommunityGalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_image_versions = GalleryImageVersionsOperations( + self.community_gallery_images = CommunityGalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_applications = GalleryApplicationsOperations( + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( + self.shared_galleries = SharedGalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_sharing_profile = GallerySharingProfileOperations( + self.shared_gallery_images = SharedGalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_galleries = SharedGalleriesOperations( + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_gallery_images = SharedGalleryImagesOperations( + self.gallery_applications = GalleryApplicationsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self.gallery_application_versions = GalleryApplicationVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_galleries = CommunityGalleriesOperations( + self.gallery_images = GalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_gallery_images = CommunityGalleryImagesOperations( + self.gallery_image_versions = GalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self.gallery_sharing_profile = GallerySharingProfileOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_configuration.py index 943bc0daf2a2..c1440ab3b306 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_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 "2023-07-03". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_metadata.json index f6fbea438a5d..8b7402323e4a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_metadata.json +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/_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,16 +106,16 @@ }, "operation_groups": { "galleries": "GalleriesOperations", - "gallery_images": "GalleryImagesOperations", - "gallery_image_versions": "GalleryImageVersionsOperations", - "gallery_applications": "GalleryApplicationsOperations", - "gallery_application_versions": "GalleryApplicationVersionsOperations", - "gallery_sharing_profile": "GallerySharingProfileOperations", + "community_galleries": "CommunityGalleriesOperations", + "community_gallery_images": "CommunityGalleryImagesOperations", + "community_gallery_image_versions": "CommunityGalleryImageVersionsOperations", "shared_galleries": "SharedGalleriesOperations", "shared_gallery_images": "SharedGalleryImagesOperations", "shared_gallery_image_versions": "SharedGalleryImageVersionsOperations", - "community_galleries": "CommunityGalleriesOperations", - "community_gallery_images": "CommunityGalleryImagesOperations", - "community_gallery_image_versions": "CommunityGalleryImageVersionsOperations" + "gallery_applications": "GalleryApplicationsOperations", + "gallery_application_versions": "GalleryApplicationVersionsOperations", + "gallery_images": "GalleryImagesOperations", + "gallery_image_versions": "GalleryImageVersionsOperations", + "gallery_sharing_profile": "GallerySharingProfileOperations" } } 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py index 4e35f9b73058..8ee444838ebc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_compute_management_client.py @@ -42,29 +42,6 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar galleries: GalleriesOperations operations :vartype galleries: azure.mgmt.compute.v2023_07_03.aio.operations.GalleriesOperations - :ivar gallery_images: GalleryImagesOperations operations - :vartype gallery_images: azure.mgmt.compute.v2023_07_03.aio.operations.GalleryImagesOperations - :ivar gallery_image_versions: GalleryImageVersionsOperations operations - :vartype gallery_image_versions: - azure.mgmt.compute.v2023_07_03.aio.operations.GalleryImageVersionsOperations - :ivar gallery_applications: GalleryApplicationsOperations operations - :vartype gallery_applications: - azure.mgmt.compute.v2023_07_03.aio.operations.GalleryApplicationsOperations - :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations - :vartype gallery_application_versions: - azure.mgmt.compute.v2023_07_03.aio.operations.GalleryApplicationVersionsOperations - :ivar gallery_sharing_profile: GallerySharingProfileOperations operations - :vartype gallery_sharing_profile: - azure.mgmt.compute.v2023_07_03.aio.operations.GallerySharingProfileOperations - :ivar shared_galleries: SharedGalleriesOperations operations - :vartype shared_galleries: - azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleriesOperations - :ivar shared_gallery_images: SharedGalleryImagesOperations operations - :vartype shared_gallery_images: - azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleryImagesOperations - :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations - :vartype shared_gallery_image_versions: - azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleryImageVersionsOperations :ivar community_galleries: CommunityGalleriesOperations operations :vartype community_galleries: azure.mgmt.compute.v2023_07_03.aio.operations.CommunityGalleriesOperations @@ -74,10 +51,32 @@ class ComputeManagementClient: # pylint: disable=too-many-instance-attributes :ivar community_gallery_image_versions: CommunityGalleryImageVersionsOperations operations :vartype community_gallery_image_versions: azure.mgmt.compute.v2023_07_03.aio.operations.CommunityGalleryImageVersionsOperations + :ivar shared_galleries: SharedGalleriesOperations operations + :vartype shared_galleries: + azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleriesOperations + :ivar shared_gallery_images: SharedGalleryImagesOperations operations + :vartype shared_gallery_images: + azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleryImagesOperations + :ivar shared_gallery_image_versions: SharedGalleryImageVersionsOperations operations + :vartype shared_gallery_image_versions: + azure.mgmt.compute.v2023_07_03.aio.operations.SharedGalleryImageVersionsOperations + :ivar gallery_applications: GalleryApplicationsOperations operations + :vartype gallery_applications: + azure.mgmt.compute.v2023_07_03.aio.operations.GalleryApplicationsOperations + :ivar gallery_application_versions: GalleryApplicationVersionsOperations operations + :vartype gallery_application_versions: + azure.mgmt.compute.v2023_07_03.aio.operations.GalleryApplicationVersionsOperations + :ivar gallery_images: GalleryImagesOperations operations + :vartype gallery_images: azure.mgmt.compute.v2023_07_03.aio.operations.GalleryImagesOperations + :ivar gallery_image_versions: GalleryImageVersionsOperations operations + :vartype gallery_image_versions: + azure.mgmt.compute.v2023_07_03.aio.operations.GalleryImageVersionsOperations + :ivar gallery_sharing_profile: GallerySharingProfileOperations operations + :vartype gallery_sharing_profile: + azure.mgmt.compute.v2023_07_03.aio.operations.GallerySharingProfileOperations :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 @@ -125,37 +124,37 @@ def __init__( self.galleries = GalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_images = GalleryImagesOperations( + self.community_galleries = CommunityGalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_image_versions = GalleryImageVersionsOperations( + self.community_gallery_images = CommunityGalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_applications = GalleryApplicationsOperations( + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_application_versions = GalleryApplicationVersionsOperations( + self.shared_galleries = SharedGalleriesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.gallery_sharing_profile = GallerySharingProfileOperations( + self.shared_gallery_images = SharedGalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_galleries = SharedGalleriesOperations( + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_gallery_images = SharedGalleryImagesOperations( + self.gallery_applications = GalleryApplicationsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self.gallery_application_versions = GalleryApplicationVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_galleries = CommunityGalleriesOperations( + self.gallery_images = GalleryImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_gallery_images = CommunityGalleryImagesOperations( + self.gallery_image_versions = GalleryImageVersionsOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self.gallery_sharing_profile = GallerySharingProfileOperations( self._client, self._config, self._serialize, self._deserialize, "2023-07-03" ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_configuration.py index 1a3262717545..71f94f603194 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/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 "2023-07-03". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/__init__.py index 139d983a5840..79f57c74bf6a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/__init__.py @@ -13,17 +13,17 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import GalleriesOperations # type: ignore -from ._operations import GalleryImagesOperations # type: ignore -from ._operations import GalleryImageVersionsOperations # type: ignore -from ._operations import GalleryApplicationsOperations # type: ignore -from ._operations import GalleryApplicationVersionsOperations # type: ignore -from ._operations import GallerySharingProfileOperations # type: ignore -from ._operations import SharedGalleriesOperations # type: ignore -from ._operations import SharedGalleryImagesOperations # type: ignore -from ._operations import SharedGalleryImageVersionsOperations # type: ignore from ._operations import CommunityGalleriesOperations # type: ignore from ._operations import CommunityGalleryImagesOperations # type: ignore from ._operations import CommunityGalleryImageVersionsOperations # type: ignore +from ._operations import SharedGalleriesOperations # type: ignore +from ._operations import SharedGalleryImagesOperations # type: ignore +from ._operations import SharedGalleryImageVersionsOperations # type: ignore +from ._operations import GalleryApplicationsOperations # type: ignore +from ._operations import GalleryApplicationVersionsOperations # type: ignore +from ._operations import GalleryImagesOperations # type: ignore +from ._operations import GalleryImageVersionsOperations # type: ignore +from ._operations import GallerySharingProfileOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -31,17 +31,17 @@ __all__ = [ "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", "CommunityGalleriesOperations", "CommunityGalleryImagesOperations", "CommunityGalleryImageVersionsOperations", + "SharedGalleriesOperations", + "SharedGalleryImagesOperations", + "SharedGalleryImageVersionsOperations", + "GalleryApplicationsOperations", + "GalleryApplicationVersionsOperations", + "GalleryImagesOperations", + "GalleryImageVersionsOperations", + "GallerySharingProfileOperations", ] __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/v2023_07_03/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_operations.py index e0720ea80b01..ef071fcab24a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/aio/operations/_operations.py @@ -101,6 +101,232 @@ 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.Gallery"]: + """List galleries under a subscription. + + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :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 "2023-07-03")) + cls: ClsType[_models.GalleryList] = 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_galleries_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("GalleryList", 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) + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Gallery"]: + """List galleries 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 Gallery or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :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 "2023-07-03")) + cls: ClsType[_models.GalleryList] = 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_galleries_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("GalleryList", 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) + 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) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + gallery_name: str, + *, + select: Optional[Union[str, _models.SelectPermissions]] = None, + expand: Optional[Union[str, _models.GalleryExpandParams]] = None, + **kwargs: Any + ) -> _models.Gallery: + """Retrieves information about a Shared Image Gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :keyword select: The select expression to apply on the operation. "Permissions" Default value + is None. + :paramtype select: str or ~azure.mgmt.compute.v2023_07_03.models.SelectPermissions + :keyword expand: The expand query option to apply on the operation. "SharingProfile/Groups" + Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExpandParams + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.Gallery + :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 "2023-07-03")) + cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) + + _request = build_galleries_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + subscription_id=self._config.subscription_id, + select=select, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Gallery", 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, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: @@ -154,12 +380,21 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 @@ -175,11 +410,10 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Required. @@ -205,11 +439,10 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Required. @@ -229,11 +462,10 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Is either a Gallery type or a IO[bytes] type. Required. @@ -274,7 +506,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: @@ -341,18 +575,24 @@ 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): pass 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) + + 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 @@ -368,11 +608,10 @@ async def begin_update( ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. :type gallery: ~azure.mgmt.compute.v2023_07_03.models.GalleryUpdate @@ -397,11 +636,10 @@ async def begin_update( ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. :type gallery: IO[bytes] @@ -424,11 +662,10 @@ async def begin_update( ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Is either a GalleryUpdate type or a IO[bytes] type. Required. @@ -469,7 +706,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: @@ -485,76 +724,6 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get( - self, - resource_group_name: str, - gallery_name: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = None, - expand: Optional[Union[str, _models.GalleryExpandParams]] = None, - **kwargs: Any - ) -> _models.Gallery: - """Retrieves information about a Shared Image Gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. Required. - :type gallery_name: str - :keyword select: The select expression to apply on the operation. "Permissions" Default value - is None. - :paramtype select: str or ~azure.mgmt.compute.v2023_07_03.models.SelectPermissions - :keyword expand: The expand query option to apply on the operation. "SharingProfile/Groups" - Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.Gallery - :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 "2023-07-03")) - cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) - - _request = build_galleries_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - subscription_id=self._config.subscription_id, - select=select, - 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("Gallery", 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, gallery_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -594,12 +763,18 @@ async def _delete_initial(self, resource_group_name: str, gallery_name: str, **k except (StreamConsumedError, StreamClosedError): pass 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) + + 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 @@ -607,9 +782,10 @@ async def _delete_initial(self, resource_group_name: str, gallery_name: str, **k async def begin_delete(self, resource_group_name: str, gallery_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery to be deleted. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] @@ -641,7 +817,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: @@ -655,22 +833,39 @@ 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.Gallery"]: - """List galleries 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 Gallery or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) +class CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) - cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`community_galleries` 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, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: + """Get a community gallery by gallery public name. + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :return: CommunityGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -679,72 +874,83 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy } 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_galleries_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) + cls: ClsType[_models.CommunityGallery] = 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_community_galleries_get_request( + location=location, + public_gallery_name=public_gallery_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("GalleryList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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("CommunityGallery", 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 + + +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_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 - def list(self, **kwargs: Any) -> AsyncIterable["_models.Gallery"]: - """List galleries under a subscription. + def list( + self, location: str, public_gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommunityGalleryImage"]: + """List community gallery images inside a gallery. - :return: An iterator like instance of either Gallery or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] :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 "2023-07-03")) - cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) + cls: ClsType[_models.CommunityGalleryImageList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -757,7 +963,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Gallery"]: def prepare_request(next_link=None): if not next_link: - _request = build_galleries_list_request( + _request = build_community_gallery_images_list_request( + location=location, + public_gallery_name=public_gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -783,7 +991,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryList", pipeline_response) + deserialized = self._deserialize("CommunityGalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -800,489 +1008,46 @@ 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) + @distributed_trace_async + async def get( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.CommunityGalleryImage: + """Get a community gallery image. -class GalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :return: CommunityGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage + :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.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`gallery_images` 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 "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImage] = 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") - - async def _create_or_update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImage, 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 "2023-07-03")) - 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(gallery_image, (IOBase, bytes)): - _content = gallery_image - else: - _json = self._serialize.body(gallery_image, "GalleryImage") - - _request = build_gallery_images_create_or_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_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, 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, - gallery_name: str, - gallery_image_name: str, - gallery_image: _models.GalleryImage, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. - Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage - :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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. - Required. - :type gallery_image: 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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImage, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. Is - either a GalleryImage type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImage] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image=gallery_image, - 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("GalleryImage", 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.GalleryImage].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryImage]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, 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 "2023-07-03")) - 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(gallery_image, (IOBase, bytes)): - _content = gallery_image - else: - _json = self._serialize.body(gallery_image, "GalleryImageUpdate") - - _request = build_gallery_images_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_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]: - 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_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: _models.GalleryImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate - :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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Required. - :type gallery_image: 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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImage]: - """Update a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImage] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image=gallery_image, - 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("GalleryImage", 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.GalleryImage].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryImage]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.GalleryImage: - """Retrieves information about a gallery image definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery from which the Image Definitions are - to be retrieved. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. - :type gallery_image_name: str - :return: GalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage - :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 "2023-07-03")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - - _request = build_gallery_images_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_community_gallery_images_get_request( + location=location, + public_gallery_name=public_gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -1300,18 +1065,151 @@ async def get( 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) - deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) + deserialized = self._deserialize("CommunityGalleryImage", 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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + +class CommunityGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` 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, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an image. + + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :return: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] + :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 "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImageVersionList] = 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_community_gallery_image_versions_list_request( + location=location, + public_gallery_name=public_gallery_name, + gallery_image_name=gallery_image_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("CommunityGalleryImageVersionList", 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) + 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) + + @distributed_trace_async + async def get( + self, + location: str, + public_gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> _models.CommunityGalleryImageVersion: + """Get a community gallery image version. + + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the community gallery image version. Needs to + follow semantic version name pattern: The allowed characters are digit and period. Digits must + be within the range of a 32-bit integer. Format: :code:``.\\ + :code:``.\\ :code:``. Required. + :type gallery_image_version_name: str + :return: CommunityGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1324,12 +1222,13 @@ 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 "2023-07-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.CommunityGalleryImageVersion] = kwargs.pop("cls", None) - _request = build_gallery_images_delete_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_community_gallery_image_versions_get_request( + location=location, + public_gallery_name=public_gallery_name, gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1337,108 +1236,67 @@ 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CommunityGalleryImageVersion", 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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery image. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be deleted. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be deleted. Required. - :type gallery_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 {}) +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) - 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, - gallery_name=gallery_name, - gallery_image_name=gallery_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) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`shared_galleries` 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 - def list_by_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImage"]: - """List gallery image definitions in a gallery. + def list( + self, location: str, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> AsyncIterable["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery from which Image Definitions are to - be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryImage or the result of cls(response) + :param location: The name of Azure region. Required. + :type location: str + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGallery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] :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 "2023-07-03")) - cls: ClsType[_models.GalleryImageList] = kwargs.pop("cls", None) + cls: ClsType[_models.SharedGalleryList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1451,10 +1309,10 @@ def list_by_gallery( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_images_list_by_gallery_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_galleries_list_request( + location=location, subscription_id=self._config.subscription_id, + shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, @@ -1479,7 +1337,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", pipeline_response) + deserialized = self._deserialize("SharedGalleryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1496,276 +1354,25 @@ 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`gallery_image_versions` 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersion, 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 "2023-07-03")) - 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(gallery_image_version, (IOBase, bytes)): - _content = gallery_image_version - else: - _json = self._serialize.body(gallery_image_version, "GalleryImageVersion") - - _request = build_gallery_image_versions_create_or_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_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, 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: _models.GalleryImageVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion - :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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Required. - :type gallery_image_version: 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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Is either a GalleryImageVersion type or a IO[bytes] type. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImageVersion] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, - gallery_image_version=gallery_image_version, - 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("GalleryImageVersion", 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.GalleryImageVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryImageVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + async def get(self, location: str, gallery_unique_name: str, **kwargs: Any) -> _models.SharedGallery: + """Get a shared gallery by subscription id or tenant id. + + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :return: SharedGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1774,38 +1381,23 @@ 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 "2023-07-03")) - 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(gallery_image_version, (IOBase, bytes)): - _content = gallery_image_version - else: - _json = self._serialize.body(gallery_image_version, "GalleryImageVersionUpdate") + cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) - _request = build_gallery_image_versions_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, + _request = build_shared_galleries_get_request( + location=location, + gallery_unique_name=gallery_unique_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 ) @@ -1813,213 +1405,146 @@ 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("SharedGallery", 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: _models.GalleryImageVersionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version - operation. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate - :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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - async def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version - operation. Required. - :type gallery_image_version: 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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ + models = _models - @distributed_trace_async - async def begin_update( + 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + location: str, + gallery_unique_name: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. + ) -> AsyncIterable["_models.SharedGalleryImage"]: + """List shared gallery images by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version - operation. Is either a GalleryImageVersionUpdate type or a IO[bytes] type. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of - cls(response) + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImageVersion] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, - gallery_image_version=gallery_image_version, - 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.SharedGalleryImageList] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) + 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_shared_gallery_images_list_request( + location=location, + gallery_unique_name=gallery_unique_name, + subscription_id=self._config.subscription_id, + shared_to=shared_to, + 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("SharedGalleryImageList", 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, 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[_models.GalleryImageVersion].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[_models.GalleryImageVersion]( - 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) + 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) @distributed_trace_async async def get( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, - **kwargs: Any - ) -> _models.GalleryImageVersion: - """Retrieves information about a gallery image version. + self, location: str, gallery_unique_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.SharedGalleryImage: + """Get a shared gallery image by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - resides. Required. + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be retrieved. - Required. - :type gallery_image_version_name: str - :keyword expand: The expand expression to apply on the operation. Known values are: - "ReplicationStatus" and "UefiSettings". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion + :return: SharedGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2034,15 +1559,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 "2023-07-03")) - cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) - _request = build_gallery_image_versions_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_gallery_images_get_request( + location=location, + gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -2058,23 +1581,163 @@ async def get( 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) - deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) + deserialized = self._deserialize("SharedGalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( + +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` 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, - gallery_name: str, + location: str, + gallery_unique_name: str, + gallery_image_name: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions by subscription id or tenant id. + + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. + :type gallery_image_name: str + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] + :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 "2023-07-03")) + cls: ClsType[_models.SharedGalleryImageVersionList] = 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_shared_gallery_image_versions_list_request( + location=location, + gallery_unique_name=gallery_unique_name, + gallery_image_name=gallery_image_name, + subscription_id=self._config.subscription_id, + shared_to=shared_to, + 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("SharedGalleryImageVersionList", 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) + 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) + + @distributed_trace_async + async def get( + self, + location: str, + gallery_unique_name: str, gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + ) -> _models.SharedGalleryImageVersion: + """Get a shared gallery image version by subscription id or tenant id. + + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be created. Needs + to follow semantic version name pattern: The allowed characters are digit and period. Digits + must be within the range of a 32-bit integer. Format: :code:``.\\ + :code:``.\\ :code:``. Required. + :type gallery_image_version_name: str + :return: SharedGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2087,11 +1750,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 "2023-07-03")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - _request = build_gallery_image_versions_delete_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_gallery_image_versions_get_request( + location=location, + gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, @@ -2101,121 +1764,67 @@ 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("SharedGalleryImageVersion", 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Delete a gallery image version. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - resides. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be deleted. - Required. - :type gallery_image_version_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 GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) - 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_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.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`gallery_applications` 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 - def list_by_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersion"]: - """List gallery image versions in a gallery image definition. + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryApplication"]: + """List gallery Application Definitions in a gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the Shared Image Gallery Image Definition from which the - Image Versions are to be listed. Required. - :type gallery_image_name: str - :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) + :return: An iterator like instance of either GalleryApplication or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :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 "2023-07-03")) - cls: ClsType[_models.GalleryImageVersionList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplicationList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2228,10 +1837,9 @@ def list_by_gallery_image( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_image_versions_list_by_gallery_image_request( + _request = build_gallery_applications_list_by_gallery_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2257,7 +1865,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageVersionList", pipeline_response) + deserialized = self._deserialize("GalleryApplicationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2274,32 +1882,74 @@ 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) + @distributed_trace_async + async def get( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> _models.GalleryApplication: + """Retrieves information about a gallery Application Definition. -class GalleryApplicationsOperations: - """ - .. 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :return: GalleryApplication or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication + :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.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`gallery_applications` 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 "2023-07-03")) + cls: ClsType[_models.GalleryApplication] = 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_gallery_applications_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_application_name=gallery_application_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -2360,12 +2010,21 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 @@ -2382,14 +2041,13 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. @@ -2417,14 +2075,13 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. @@ -2450,14 +2107,13 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Is either a GalleryApplication type or a IO[bytes] type. Required. @@ -2570,18 +2226,24 @@ 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): pass 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) + + 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 @@ -2598,14 +2260,13 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Required. @@ -2633,14 +2294,13 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Required. @@ -2666,14 +2326,13 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Is either a GalleryApplicationUpdate type or a IO[bytes] type. Required. @@ -2717,7 +2376,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: @@ -2733,67 +2394,6 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace_async - async def get( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> _models.GalleryApplication: - """Retrieves information about a gallery Application Definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery from which the Application - Definitions are to be retrieved. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be - retrieved. Required. - :type gallery_application_name: str - :return: GalleryApplication or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication - :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) - - _request = build_gallery_applications_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_application_name=gallery_application_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("GalleryApplication", 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, gallery_name: str, gallery_application_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -2836,12 +2436,18 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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 @@ -2851,13 +2457,13 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Delete a gallery Application. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be deleted. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] @@ -2890,7 +2496,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: @@ -2904,27 +2512,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 GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` 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_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplication"]: - """List gallery Application Definitions in a gallery. + def list_by_gallery_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryApplicationVersion"]: + """List gallery Application Versions in a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery from which Application - Definitions are to be listed. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :return: An iterator like instance of either GalleryApplicationVersion or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplicationVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2937,9 +2570,10 @@ def list_by_gallery( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_applications_list_by_gallery_request( + _request = build_gallery_application_versions_list_by_gallery_application_request( resource_group_name=resource_group_name, gallery_name=gallery_name, + gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2965,7 +2599,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", pipeline_response) + deserialized = self._deserialize("GalleryApplicationVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2982,32 +2616,89 @@ 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) + @distributed_trace_async + async def get( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + *, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + """Retrieves information about a gallery Application Version. -class GalleryApplicationVersionsOperations: - """ - .. 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :keyword expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion + :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.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`gallery_application_versions` 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 "2023-07-03")) + cls: ClsType[_models.GalleryApplicationVersion] = 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_gallery_application_versions_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -3070,12 +2761,21 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 @@ -3093,18 +2793,16 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Required. @@ -3134,18 +2832,16 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Required. @@ -3172,18 +2868,16 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Is either a GalleryApplicationVersion type or a IO[bytes] type. @@ -3229,7 +2923,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: @@ -3300,18 +2996,24 @@ 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): pass 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) + + 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 @@ -3329,18 +3031,16 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Required. @@ -3370,18 +3070,16 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Required. @@ -3408,154 +3106,78 @@ async def begin_update( ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + retrieved. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Is either a GalleryApplicationVersionUpdate type or a IO[bytes] type. Required. :type gallery_application_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] - :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplicationVersion] = 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, - gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, - gallery_application_version=gallery_application_version, - 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("GalleryApplicationVersion", 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.GalleryApplicationVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GalleryApplicationVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, - **kwargs: Any - ) -> _models.GalleryApplicationVersion: - """Retrieves information about a gallery Application Version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version resides. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - retrieved. Required. - :type gallery_application_version_name: str - :keyword expand: The expand expression to apply on the operation. Known values are: - "ReplicationStatus" and "UefiSettings". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion - :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) - - _request = build_gallery_application_versions_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_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) + :return: An instance of AsyncLROPoller that returns either GalleryApplicationVersion or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryApplicationVersion] = 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, + gallery_name=gallery_name, + gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_name, + gallery_application_version=gallery_application_version, + 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 cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryApplicationVersion", 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.GalleryApplicationVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryApplicationVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, @@ -3605,12 +3227,18 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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 @@ -3625,16 +3253,16 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Delete a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version resides. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be - deleted. Required. + retrieved. Required. :type gallery_application_version_name: str :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] @@ -3668,7 +3296,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: @@ -3682,31 +3312,48 @@ 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 GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s + :attr:`gallery_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 - def list_by_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersion"]: - """List gallery Application Versions in a gallery Application Definition. + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryImage"]: + """List gallery image definitions in a gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the Shared Application Gallery Application - Definition from which the Application Versions are to be listed. Required. - :type gallery_application_name: str - :return: An iterator like instance of either GalleryApplicationVersion or the result of - cls(response) + :return: An iterator like instance of either GalleryImage or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationVersionList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImageList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3719,10 +3366,9 @@ def list_by_gallery_application( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_application_versions_list_by_gallery_application_request( + _request = build_gallery_images_list_by_gallery_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3748,7 +3394,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationVersionList", pipeline_response) + deserialized = self._deserialize("GalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -3765,38 +3411,80 @@ 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) + @distributed_trace_async + async def get( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.GalleryImage: + """Retrieves information about a gallery image definition. -class GallerySharingProfileOperations: - """ - .. 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :return: GalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage + :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.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` 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 "2023-07-03")) + cls: ClsType[_models.GalleryImage] = 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_gallery_images_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_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 _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryImage", 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, gallery_name: str, - sharing_update: Union[_models.SharingUpdate, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3817,14 +3505,15 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(sharing_update, (IOBase, bytes)): - _content = sharing_update + if isinstance(gallery_image, (IOBase, bytes)): + _content = gallery_image else: - _json = self._serialize.body(sharing_update, "SharingUpdate") + _json = self._serialize.body(gallery_image, "GalleryImage") - _request = build_gallery_sharing_profile_update_request( + _request = build_gallery_images_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, + gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3843,98 +3532,118 @@ async def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_create_or_update( self, resource_group_name: str, gallery_name: str, - sharing_update: _models.SharingUpdate, + gallery_image_name: str, + gallery_image: _models.GalleryImage, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. + ) -> AsyncLROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. - :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. + Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage :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 SharingUpdate or the result of + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - sharing_update: IO[bytes], + gallery_image_name: str, + gallery_image: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. + ) -> AsyncLROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. - :type sharing_update: IO[bytes] + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. + Required. + :type gallery_image: 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 SharingUpdate or the result of + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - sharing_update: Union[_models.SharingUpdate, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. + ) -> AsyncLROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Is either a - SharingUpdate type or a IO[bytes] type. Required. - :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SharingUpdate or the result of + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. Is + either a GalleryImage type or a IO[bytes] type. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3942,15 +3651,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharingUpdate] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImage] = 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._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, - sharing_update=sharing_update, + gallery_image_name=gallery_image_name, + gallery_image=gallery_image, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3962,145 +3672,38 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharingUpdate", pipeline_response.http_response) + deserialized = self._deserialize("GalleryImage", 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.SharingUpdate].from_continuation_token( + return AsyncLROPoller[_models.GalleryImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.SharingUpdate]( + return AsyncLROPoller[_models.GalleryImage]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - -class SharedGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`shared_galleries` 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, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGallery"]: - """List shared galleries by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGallery or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] - :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryList] = 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_shared_galleries_list_request( - location=location, - subscription_id=self._config.subscription_id, - shared_to=shared_to, - 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("SharedGalleryList", 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, gallery_unique_name: str, **kwargs: Any) -> _models.SharedGallery: - """Get a shared gallery by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :return: SharedGallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGallery - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4109,170 +3712,205 @@ async def get(self, location: str, gallery_unique_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 "2023-07-03")) - cls: ClsType[_models.SharedGallery] = 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_shared_galleries_get_request( - location=location, - gallery_unique_name=gallery_unique_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image, (IOBase, bytes)): + _content = gallery_image + else: + _json = self._serialize.body(gallery_image, "GalleryImageUpdate") + + _request = build_gallery_images_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_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) - _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedGallery", 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, + gallery_name: str, + gallery_image_name: str, + gallery_image: _models.GalleryImageUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImage]: + """Update a gallery image definition. -class SharedGalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`shared_gallery_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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate + :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 GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + :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_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImage]: + """Update a gallery image definition. - @distributed_trace - def list( + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Required. + :type gallery_image: 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 GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( self, - location: str, - gallery_unique_name: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImage"]: - """List shared gallery images by subscription id or tenant id. + ) -> AsyncLROPoller[_models.GalleryImage]: + """Update a gallery image definition. - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Is either a + GalleryImageUpdate type or a IO[bytes] type. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageList] = 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_shared_gallery_images_list_request( - location=location, - gallery_unique_name=gallery_unique_name, - subscription_id=self._config.subscription_id, - shared_to=shared_to, - 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[_models.GalleryImage] = 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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image=gallery_image, + 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("SharedGalleryImageList", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) 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, 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) ) - 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, gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.SharedGalleryImage: - """Get a shared gallery image by subscription id or tenant id. + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.GalleryImage].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryImage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. - :type gallery_image_name: str - :return: SharedGalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _delete_initial( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4285,11 +3923,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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_shared_gallery_images_get_request( - location=location, - gallery_unique_name=gallery_unique_name, + _request = build_gallery_images_delete_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -4298,78 +3936,139 @@ async def get( ) _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedGalleryImage", 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 begin_delete( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a gallery image. -class SharedGalleryImageVersionsOperations: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_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 "2023-07-03")) + 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, + gallery_name=gallery_name, + gallery_image_name=gallery_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, 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 GalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. + :attr:`gallery_image_versions` 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, - gallery_unique_name: str, - gallery_image_name: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions by subscription id or tenant id. + 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 location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. + @distributed_trace + def list_by_gallery_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GalleryImageVersion"]: + """List gallery image versions in a gallery image definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. :type gallery_image_name: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImageVersion or the result of - cls(response) + :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageVersionList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImageVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4382,12 +4081,11 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_shared_gallery_image_versions_list_request( - location=location, - gallery_unique_name=gallery_unique_name, + _request = build_gallery_image_versions_list_by_gallery_image_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, - shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, @@ -4412,7 +4110,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("SharedGalleryImageVersionList", pipeline_response) + deserialized = self._deserialize("GalleryImageVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4429,7 +4127,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 @@ -4438,30 +4137,324 @@ async def get_next(next_link=None): @distributed_trace_async async def get( self, - location: str, - gallery_unique_name: str, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + *, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, + **kwargs: Any + ) -> _models.GalleryImageVersion: + """Retrieves information about a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :keyword expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion + :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 "2023-07-03")) + cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_gallery_image_versions_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryImageVersion", 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, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersion, 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 "2023-07-03")) + 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(gallery_image_version, (IOBase, bytes)): + _content = gallery_image_version + else: + _json = self._serialize.body(gallery_image_version, "GalleryImageVersion") + + _request = build_gallery_image_versions_create_or_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: _models.GalleryImageVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion + :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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Required. + :type gallery_image_version: 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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version by subscription id or tenant id. + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. :type gallery_image_version_name: str - :return: SharedGalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Is either a GalleryImageVersion type or a IO[bytes] type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryImageVersion] = 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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, + gallery_image_version=gallery_image_version, + 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("GalleryImageVersion", 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.GalleryImageVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryImageVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4470,154 +4463,230 @@ 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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageVersion] = 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_shared_gallery_image_versions_get_request( - location=location, - gallery_unique_name=gallery_unique_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IOBase, bytes)): + _content = gallery_image_version + else: + _json = self._serialize.body(gallery_image_version, "GalleryImageVersionUpdate") + + _request = build_gallery_image_versions_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedGalleryImageVersion", 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, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: _models.GalleryImageVersionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`community_galleries` 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") + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate + :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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace_async - async def get(self, location: str, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: - """Get a community gallery by gallery public name. + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :return: CommunityGallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGallery + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Required. + :type gallery_image_version: 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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 {} + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Is either a GalleryImageVersionUpdate type or a IO[bytes] type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :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 "2023-07-03")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryImageVersion] = 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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, + gallery_image_version=gallery_image_version, + 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_community_galleries_get_request( - location=location, - public_gallery_name=public_gallery_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("GalleryImageVersion", 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.GalleryImageVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GalleryImageVersion]( + 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("CommunityGallery", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`community_gallery_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, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.CommunityGalleryImage: - """Get a community gallery image. - - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :return: CommunityGalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _delete_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4630,12 +4699,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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_community_gallery_images_get_request( - location=location, - public_gallery_name=public_gallery_name, + _request = build_gallery_image_versions_delete_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4643,117 +4713,113 @@ async def get( ) _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommunityGalleryImage", 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, location: str, public_gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CommunityGalleryImage"]: - """List community gallery images inside a gallery. + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a gallery image version. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :return: An iterator like instance of either CommunityGalleryImage or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageList] = 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_community_gallery_images_list_request( - location=location, - public_gallery_name=public_gallery_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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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("CommunityGalleryImageList", 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 -class CommunityGalleryImageVersionsOperations: +class GallerySharingProfileOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2023_07_03.aio.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. + :attr:`gallery_sharing_profile` attribute. """ models = _models @@ -4766,32 +4832,13 @@ 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( + async def _update_initial( self, - location: str, - public_gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO[bytes]], **kwargs: Any - ) -> _models.CommunityGalleryImageVersion: - """Get a community gallery image version. - - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the community gallery image version. Needs to - follow semantic version name pattern: The allowed characters are digit and period. Digits must - be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :return: CommunityGalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4800,125 +4847,190 @@ 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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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_community_gallery_image_versions_get_request( - location=location, - public_gallery_name=public_gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sharing_update, (IOBase, bytes)): + _content = sharing_update + else: + _json = self._serialize.body(sharing_update, "SharingUpdate") + + _request = build_gallery_sharing_profile_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommunityGalleryImageVersion", 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, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an image. + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: _models.SharingUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :return: An iterator like instance of either CommunityGalleryImageVersion 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. + :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate + :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 SharingUpdate or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] :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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageVersionList] = kwargs.pop("cls", None) + @overload + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. + :type sharing_update: 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 SharingUpdate or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - _request = build_community_gallery_image_versions_list_request( - location=location, - public_gallery_name=public_gallery_name, - gallery_image_name=gallery_image_name, - subscription_id=self._config.subscription_id, - 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Is either a + SharingUpdate type or a IO[bytes] type. Required. + :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharingUpdate] = 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, + gallery_name=gallery_name, + sharing_update=sharing_update, + 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("CommunityGalleryImageVersionList", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharingUpdate", pipeline_response.http_response) 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, 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) ) - 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[_models.SharingUpdate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SharingUpdate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/__init__.py index e97c8bf11e64..e6d12f8f2bdf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/__init__.py @@ -28,6 +28,9 @@ Disallowed, DiskImageEncryption, EncryptionImages, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, ExtendedLocation, Gallery, GalleryApplication, @@ -42,7 +45,6 @@ GalleryApplicationVersionUpdate, GalleryArtifactPublishingProfileBase, GalleryArtifactSafetyProfileBase, - GalleryArtifactSource, GalleryArtifactVersionFullSource, GalleryArtifactVersionSource, GalleryDataDiskImage, @@ -69,8 +71,6 @@ ImagePurchasePlan, ImageVersionSecurityProfile, InnerError, - LatestGalleryImageVersion, - ManagedArtifact, OSDiskImageEncryption, OSDiskImageSecurityProfile, PirCommunityGalleryResource, @@ -82,6 +82,7 @@ RegionalSharingStatus, ReplicationStatus, Resource, + ResourceAutoGenerated, ResourceRange, ResourceWithOptionalLocation, SharedGallery, @@ -102,7 +103,9 @@ SubResource, SubResourceReadOnly, SystemData, + SystemDataAutoGenerated, TargetRegion, + TrackedResource, UefiKey, UefiKeySignatures, UpdateResourceDefinition, @@ -116,6 +119,7 @@ AggregatedReplicationState, Architecture, ConfidentialVMEncryptionType, + CreatedByType, EdgeZoneStorageAccountType, ExtendedLocationTypes, GalleryApplicationCustomActionParameterType, @@ -160,6 +164,9 @@ "Disallowed", "DiskImageEncryption", "EncryptionImages", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ExtendedLocation", "Gallery", "GalleryApplication", @@ -174,7 +181,6 @@ "GalleryApplicationVersionUpdate", "GalleryArtifactPublishingProfileBase", "GalleryArtifactSafetyProfileBase", - "GalleryArtifactSource", "GalleryArtifactVersionFullSource", "GalleryArtifactVersionSource", "GalleryDataDiskImage", @@ -201,8 +207,6 @@ "ImagePurchasePlan", "ImageVersionSecurityProfile", "InnerError", - "LatestGalleryImageVersion", - "ManagedArtifact", "OSDiskImageEncryption", "OSDiskImageSecurityProfile", "PirCommunityGalleryResource", @@ -214,6 +218,7 @@ "RegionalSharingStatus", "ReplicationStatus", "Resource", + "ResourceAutoGenerated", "ResourceRange", "ResourceWithOptionalLocation", "SharedGallery", @@ -234,7 +239,9 @@ "SubResource", "SubResourceReadOnly", "SystemData", + "SystemDataAutoGenerated", "TargetRegion", + "TrackedResource", "UefiKey", "UefiKeySignatures", "UpdateResourceDefinition", @@ -245,6 +252,7 @@ "AggregatedReplicationState", "Architecture", "ConfidentialVMEncryptionType", + "CreatedByType", "EdgeZoneStorageAccountType", "ExtendedLocationTypes", "GalleryApplicationCustomActionParameterType", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py index 09be37bb0487..5b20117890fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_compute_management_client_enums.py @@ -35,6 +35,15 @@ class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta) NON_PERSISTED_TPM = "NonPersistedTPM" +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + class EdgeZoneStorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_models_py3.py index aea884089634..a7d8a2fd19d5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/models/_models_py3.py @@ -168,6 +168,9 @@ class CommunityGallery(PirCommunityGalleryResource): "name": {"readonly": True}, "location": {"readonly": True}, "type": {"readonly": True}, + "disclaimer": {"readonly": True}, + "artifact_tags": {"readonly": True}, + "community_metadata": {"readonly": True}, } _attribute_map = { @@ -180,29 +183,15 @@ class CommunityGallery(PirCommunityGalleryResource): "community_metadata": {"key": "properties.communityMetadata", "type": "CommunityGalleryMetadata"}, } - def __init__( - self, - *, - unique_id: Optional[str] = None, - disclaimer: Optional[str] = None, - artifact_tags: Optional[Dict[str, str]] = None, - community_metadata: Optional["_models.CommunityGalleryMetadata"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, unique_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword unique_id: The unique id of this community gallery. :paramtype unique_id: str - :keyword disclaimer: The disclaimer for a community gallery resource. - :paramtype disclaimer: str - :keyword artifact_tags: The artifact tags of a community gallery resource. - :paramtype artifact_tags: dict[str, str] - :keyword community_metadata: The metadata of community gallery. - :paramtype community_metadata: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryMetadata """ super().__init__(unique_id=unique_id, **kwargs) - self.disclaimer = disclaimer - self.artifact_tags = artifact_tags - self.community_metadata = community_metadata + self.disclaimer = None + self.artifact_tags = None + self.community_metadata = None class CommunityGalleryImage(PirCommunityGalleryResource): @@ -261,6 +250,19 @@ class CommunityGalleryImage(PirCommunityGalleryResource): "name": {"readonly": True}, "location": {"readonly": True}, "type": {"readonly": True}, + "os_type": {"readonly": True}, + "os_state": {"readonly": True}, + "end_of_life_date": {"readonly": True}, + "identifier": {"readonly": True}, + "recommended": {"readonly": True}, + "hyper_v_generation": {"readonly": True}, + "features": {"readonly": True}, + "purchase_plan": {"readonly": True}, + "architecture": {"readonly": True}, + "privacy_statement_uri": {"readonly": True}, + "eula": {"readonly": True}, + "disclaimer": {"readonly": True}, + "artifact_tags": {"readonly": True}, } _attribute_map = { @@ -285,86 +287,36 @@ class CommunityGalleryImage(PirCommunityGalleryResource): } def __init__( - self, - *, - unique_id: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.CommunityGalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - privacy_statement_uri: Optional[str] = None, - eula: Optional[str] = None, - disclaimer: Optional[str] = None, - artifact_tags: Optional[Dict[str, str]] = None, - **kwargs: Any + self, *, unique_id: Optional[str] = None, disallowed: Optional["_models.Disallowed"] = None, **kwargs: Any ) -> None: """ :keyword unique_id: The unique id of this community gallery. :paramtype unique_id: str - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk when creating a VM from a managed image. Possible values are: **Windows,** **Linux.**. - Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized" - and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :keyword end_of_life_date: The end of life date of the gallery image definition. This property - can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword identifier: This is the community gallery image definition identifier. - :paramtype identifier: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - :keyword privacy_statement_uri: Privacy statement URI for the current community gallery image. - :paramtype privacy_statement_uri: str - :keyword eula: The end-user license agreement for the current community gallery image. - :paramtype eula: str - :keyword disclaimer: The disclaimer for a community gallery resource. - :paramtype disclaimer: str - :keyword artifact_tags: The artifact tags of a community gallery resource. - :paramtype artifact_tags: dict[str, str] """ super().__init__(unique_id=unique_id, **kwargs) - self.os_type = os_type - self.os_state = os_state - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended + self.os_type = None + self.os_state = None + self.end_of_life_date = None + self.identifier = None + self.recommended = None self.disallowed = disallowed - self.hyper_v_generation = hyper_v_generation - self.features = features - self.purchase_plan = purchase_plan - self.architecture = architecture - self.privacy_statement_uri = privacy_statement_uri - self.eula = eula - self.disclaimer = disclaimer - self.artifact_tags = artifact_tags + self.hyper_v_generation = None + self.features = None + self.purchase_plan = None + self.architecture = None + self.privacy_statement_uri = None + self.eula = None + self.disclaimer = None + self.artifact_tags = None class CommunityGalleryImageIdentifier(_serialization.Model): """This is the community gallery image definition identifier. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar publisher: The name of the gallery image definition publisher. :vartype publisher: str :ivar offer: The name of the gallery image definition offer. @@ -373,27 +325,24 @@ class CommunityGalleryImageIdentifier(_serialization.Model): :vartype sku: str """ + _validation = { + "publisher": {"readonly": True}, + "offer": {"readonly": True}, + "sku": {"readonly": True}, + } + _attribute_map = { "publisher": {"key": "publisher", "type": "str"}, "offer": {"key": "offer", "type": "str"}, "sku": {"key": "sku", "type": "str"}, } - def __init__( - self, *, publisher: Optional[str] = None, offer: Optional[str] = None, sku: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. - :paramtype sku: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku + self.publisher = None + self.offer = None + self.sku = None class CommunityGalleryImageList(_serialization.Model): @@ -403,8 +352,7 @@ class CommunityGalleryImageList(_serialization.Model): :ivar value: A list of community gallery images. Required. :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] - :ivar next_link: The URI to fetch the next page of community gallery images. Call ListNext() - with this to fetch the next page of community gallery images. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -423,8 +371,7 @@ def __init__( """ :keyword value: A list of community gallery images. Required. :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] - :keyword next_link: The URI to fetch the next page of community gallery images. Call ListNext() - with this to fetch the next page of community gallery images. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -467,6 +414,12 @@ class CommunityGalleryImageVersion(PirCommunityGalleryResource): "name": {"readonly": True}, "location": {"readonly": True}, "type": {"readonly": True}, + "published_date": {"readonly": True}, + "end_of_life_date": {"readonly": True}, + "exclude_from_latest": {"readonly": True}, + "storage_profile": {"readonly": True}, + "disclaimer": {"readonly": True}, + "artifact_tags": {"readonly": True}, } _attribute_map = { @@ -482,45 +435,18 @@ class CommunityGalleryImageVersion(PirCommunityGalleryResource): "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } - def __init__( - self, - *, - unique_id: Optional[str] = None, - published_date: Optional[datetime.datetime] = None, - end_of_life_date: Optional[datetime.datetime] = None, - exclude_from_latest: Optional[bool] = None, - storage_profile: Optional["_models.SharedGalleryImageVersionStorageProfile"] = None, - disclaimer: Optional[str] = None, - artifact_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, unique_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword unique_id: The unique id of this community gallery. :paramtype unique_id: str - :keyword published_date: The published date of the gallery image version Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype published_date: ~datetime.datetime - :keyword end_of_life_date: The end of life date of the gallery image version Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword exclude_from_latest: If set to true, Virtual Machines deployed from the latest version - of the Image Definition won't use this Image Version. - :paramtype exclude_from_latest: bool - :keyword storage_profile: Describes the storage profile of the image version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersionStorageProfile - :keyword disclaimer: The disclaimer for a community gallery resource. - :paramtype disclaimer: str - :keyword artifact_tags: The artifact tags of a community gallery resource. - :paramtype artifact_tags: dict[str, str] """ super().__init__(unique_id=unique_id, **kwargs) - self.published_date = published_date - self.end_of_life_date = end_of_life_date - self.exclude_from_latest = exclude_from_latest - self.storage_profile = storage_profile - self.disclaimer = disclaimer - self.artifact_tags = artifact_tags + self.published_date = None + self.end_of_life_date = None + self.exclude_from_latest = None + self.storage_profile = None + self.disclaimer = None + self.artifact_tags = None class CommunityGalleryImageVersionList(_serialization.Model): @@ -628,6 +554,8 @@ def __init__( class CommunityGalleryMetadata(_serialization.Model): """The metadata of community gallery. + 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 publisher_uri: The publisher URI of this community gallery. @@ -644,8 +572,11 @@ class CommunityGalleryMetadata(_serialization.Model): """ _validation = { - "publisher_contact": {"required": True}, - "public_names": {"required": True}, + "publisher_uri": {"readonly": True}, + "publisher_contact": {"required": True, "readonly": True}, + "eula": {"readonly": True}, + "public_names": {"required": True, "readonly": True}, + "privacy_statement_uri": {"readonly": True}, } _attribute_map = { @@ -656,35 +587,14 @@ class CommunityGalleryMetadata(_serialization.Model): "privacy_statement_uri": {"key": "privacyStatementUri", "type": "str"}, } - def __init__( - self, - *, - publisher_contact: str, - public_names: List[str], - publisher_uri: Optional[str] = None, - eula: Optional[str] = None, - privacy_statement_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher_uri: The publisher URI of this community gallery. - :paramtype publisher_uri: str - :keyword publisher_contact: The publisher email id of this community gallery. Required. - :paramtype publisher_contact: str - :keyword eula: The end-user license agreement for this community gallery. - :paramtype eula: str - :keyword public_names: A list of public names the gallery has. Required. - :paramtype public_names: list[str] - :keyword privacy_statement_uri: The link for the privacy statement of this community gallery - from the gallery publisher. - :paramtype privacy_statement_uri: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.publisher_uri = publisher_uri - self.publisher_contact = publisher_contact - self.eula = eula - self.public_names = public_names - self.privacy_statement_uri = privacy_statement_uri + self.publisher_uri = None + self.publisher_contact = None + self.eula = None + self.public_names = None + self.privacy_statement_uri = None class DiskImageEncryption(_serialization.Model): @@ -800,6 +710,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.v2023_07_03.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.compute.v2023_07_03.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.v2023_07_03.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.v2023_07_03.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class ExtendedLocation(_serialization.Model): """The complex type of the extended location. @@ -833,28 +835,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.v2023_07_03.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.v2023_07_03.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}, } @@ -862,42 +912,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 Gallery(Resource): +class Gallery(TrackedResource): """Specifies information about the Shared Image Gallery that you want to create or update. 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.v2023_07_03.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 description: The description of this Shared Image Gallery resource. This property is updatable. :vartype description: str @@ -919,6 +972,7 @@ class Gallery(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, "sharing_status": {"readonly": True}, @@ -928,8 +982,9 @@ class Gallery(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"}, "description": {"key": "properties.description", "type": "str"}, "identifier": {"key": "properties.identifier", "type": "GalleryIdentifier"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, @@ -950,10 +1005,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 description: The description of this Shared Image Gallery resource. This property is updatable. :paramtype description: str @@ -965,7 +1020,7 @@ def __init__( gallery. :paramtype soft_delete_policy: ~azure.mgmt.compute.v2023_07_03.models.SoftDeletePolicy """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.description = description self.identifier = identifier self.provisioning_state = None @@ -974,7 +1029,7 @@ def __init__( self.sharing_status = None -class GalleryApplication(Resource): +class GalleryApplication(TrackedResource): """Specifies information about the gallery Application Definition that you want to create or update. @@ -982,16 +1037,21 @@ class GalleryApplication(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.v2023_07_03.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 description: The description of this gallery Application Definition resource. This property is updatable. :vartype description: str @@ -1018,6 +1078,7 @@ class GalleryApplication(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -1025,8 +1086,9 @@ class GalleryApplication(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"}, "description": {"key": "properties.description", "type": "str"}, "eula": {"key": "properties.eula", "type": "str"}, "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, @@ -1051,10 +1113,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 description: The description of this gallery Application Definition resource. This property is updatable. :paramtype description: str @@ -1077,7 +1139,7 @@ def __init__( :paramtype custom_actions: list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationCustomAction] """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.description = description self.eula = eula self.privacy_statement_uri = privacy_statement_uri @@ -1218,10 +1280,9 @@ class GalleryApplicationList(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: A list of Gallery Applications. Required. + :ivar value: The GalleryApplication items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :ivar next_link: The uri to fetch the next page of Application Definitions in the Application - Gallery. Call ListNext() with this to fetch the next page of gallery Application Definitions. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -1238,11 +1299,9 @@ def __init__( self, *, value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: A list of Gallery Applications. Required. + :keyword value: The GalleryApplication items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] - :keyword next_link: The uri to fetch the next page of Application Definitions in the - Application Gallery. Call ListNext() with this to fetch the next page of gallery Application - Definitions. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -1393,23 +1452,28 @@ def __init__( self.custom_actions = custom_actions -class GalleryApplicationVersion(Resource): +class GalleryApplicationVersion(TrackedResource): """Specifies information about the gallery Application Version that you want to create or update. 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.v2023_07_03.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 publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionPublishingProfile @@ -1428,6 +1492,7 @@ class GalleryApplicationVersion(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, "replication_status": {"readonly": True}, @@ -1437,8 +1502,9 @@ class GalleryApplicationVersion(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"}, "publishing_profile": { "key": "properties.publishingProfile", "type": "GalleryApplicationVersionPublishingProfile", @@ -1458,10 +1524,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 publishing_profile: The publishing profile of a gallery image version. :paramtype publishing_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionPublishingProfile @@ -1469,7 +1535,7 @@ def __init__( :paramtype safety_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionSafetyProfile """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.publishing_profile = publishing_profile self.safety_profile = safety_profile self.provisioning_state = None @@ -1858,40 +1924,14 @@ def __init__( :paramtype publishing_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionPublishingProfile :keyword safety_profile: The safety profile of the Gallery Application Version. - :paramtype safety_profile: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionSafetyProfile - """ - super().__init__(tags=tags, **kwargs) - self.publishing_profile = publishing_profile - self.safety_profile = safety_profile - self.provisioning_state = None - self.replication_status = None - - -class GalleryArtifactSource(_serialization.Model): - """The source image from which the Image Version is going to be created. - - All required parameters must be populated in order to send to server. - - :ivar managed_image: The managed artifact. Required. - :vartype managed_image: ~azure.mgmt.compute.v2023_07_03.models.ManagedArtifact - """ - - _validation = { - "managed_image": {"required": True}, - } - - _attribute_map = { - "managed_image": {"key": "managedImage", "type": "ManagedArtifact"}, - } - - def __init__(self, *, managed_image: "_models.ManagedArtifact", **kwargs: Any) -> None: - """ - :keyword managed_image: The managed artifact. Required. - :paramtype managed_image: ~azure.mgmt.compute.v2023_07_03.models.ManagedArtifact + :paramtype safety_profile: + ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionSafetyProfile """ - super().__init__(**kwargs) - self.managed_image = managed_image + super().__init__(tags=tags, **kwargs) + self.publishing_profile = publishing_profile + self.safety_profile = safety_profile + self.provisioning_state = None + self.replication_status = None class GalleryArtifactVersionSource(_serialization.Model): @@ -2153,23 +2193,28 @@ def __init__(self, **kwargs: Any) -> None: self.unique_name = None -class GalleryImage(Resource): +class GalleryImage(TrackedResource): """Specifies information about the gallery image definition that you want to create or update. 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.v2023_07_03.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 description: The description of this gallery image definition resource. This property is updatable. :vartype description: str @@ -2218,6 +2263,7 @@ class GalleryImage(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, } @@ -2226,8 +2272,9 @@ class GalleryImage(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"}, "description": {"key": "properties.description", "type": "str"}, "eula": {"key": "properties.eula", "type": "str"}, "privacy_statement_uri": {"key": "properties.privacyStatementUri", "type": "str"}, @@ -2267,10 +2314,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 description: The description of this gallery image definition resource. This property is updatable. :paramtype description: str @@ -2310,7 +2357,7 @@ def __init__( are: "x64" and "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.description = description self.eula = eula self.privacy_statement_uri = privacy_statement_uri @@ -2594,23 +2641,28 @@ def __init__( self.architecture = architecture -class GalleryImageVersion(Resource): +class GalleryImageVersion(TrackedResource): """Specifies information about the gallery image version that you want to create or update. 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.v2023_07_03.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 publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile @@ -2634,6 +2686,7 @@ class GalleryImageVersion(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, "replication_status": {"readonly": True}, @@ -2643,8 +2696,9 @@ class GalleryImageVersion(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"}, "publishing_profile": {"key": "properties.publishingProfile", "type": "GalleryImageVersionPublishingProfile"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, @@ -2665,10 +2719,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 publishing_profile: The publishing profile of a gallery image Version. :paramtype publishing_profile: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionPublishingProfile @@ -2681,7 +2735,7 @@ def __init__( :keyword security_profile: The security profile of a gallery image version. :paramtype security_profile: ~azure.mgmt.compute.v2023_07_03.models.ImageVersionSecurityProfile """ - super().__init__(location=location, tags=tags, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.publishing_profile = publishing_profile self.provisioning_state = None self.storage_profile = storage_profile @@ -3248,60 +3302,6 @@ def __init__( self.errordetail = errordetail -class LatestGalleryImageVersion(_serialization.Model): - """The gallery image version with latest version in a particular region. - - :ivar latest_version_name: The name of the latest version in the region. - :vartype latest_version_name: str - :ivar location: region of the Gallery Image Version. - :vartype location: str - """ - - _attribute_map = { - "latest_version_name": {"key": "latestVersionName", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__( - self, *, latest_version_name: Optional[str] = None, location: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_version_name: The name of the latest version in the region. - :paramtype latest_version_name: str - :keyword location: region of the Gallery Image Version. - :paramtype location: str - """ - super().__init__(**kwargs) - self.latest_version_name = latest_version_name - self.location = location - - -class ManagedArtifact(_serialization.Model): - """The managed artifact. - - All required parameters must be populated in order to send to server. - - :ivar id: The managed artifact id. Required. - :vartype id: str - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The managed artifact id. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - class OSDiskImageEncryption(DiskImageEncryption): """Contains encryption settings for an OS disk image. @@ -3607,6 +3607,55 @@ def __init__(self, **kwargs: Any) -> None: self.summary = None +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 ResourceRange(_serialization.Model): """Describes the resource range. @@ -3736,6 +3785,7 @@ class SharedGalleryDiskImage(_serialization.Model): _validation = { "disk_size_gb": {"readonly": True}, + "host_caching": {"readonly": True}, } _attribute_map = { @@ -3743,17 +3793,11 @@ class SharedGalleryDiskImage(_serialization.Model): "host_caching": {"key": "hostCaching", "type": "str"}, } - def __init__( - self, *, host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs: Any - ) -> None: - """ - :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryHostCaching - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) self.disk_size_gb = None - self.host_caching = host_caching + self.host_caching = None class SharedGalleryDataDiskImage(SharedGalleryDiskImage): @@ -3776,7 +3820,8 @@ class SharedGalleryDataDiskImage(SharedGalleryDiskImage): _validation = { "disk_size_gb": {"readonly": True}, - "lun": {"required": True}, + "host_caching": {"readonly": True}, + "lun": {"required": True, "readonly": True}, } _attribute_map = { @@ -3785,20 +3830,10 @@ class SharedGalleryDataDiskImage(SharedGalleryDiskImage): "lun": {"key": "lun", "type": "int"}, } - def __init__( - self, *, lun: int, host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs: Any - ) -> None: - """ - :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Known values are: "None", "ReadOnly", and "ReadWrite". - :paramtype host_caching: str or ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryHostCaching - :keyword lun: This property specifies the logical unit number of the data disk. This value is - used to identify data disks within the Virtual Machine and therefore must be unique for each - data disk attached to the Virtual Machine. Required. - :paramtype lun: int - """ - super().__init__(host_caching=host_caching, **kwargs) - self.lun = lun + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.lun = None class SharedGalleryImage(PirSharedGalleryResource): @@ -3852,6 +3887,18 @@ class SharedGalleryImage(PirSharedGalleryResource): _validation = { "name": {"readonly": True}, "location": {"readonly": True}, + "os_type": {"readonly": True}, + "os_state": {"readonly": True}, + "end_of_life_date": {"readonly": True}, + "identifier": {"readonly": True}, + "recommended": {"readonly": True}, + "hyper_v_generation": {"readonly": True}, + "features": {"readonly": True}, + "purchase_plan": {"readonly": True}, + "architecture": {"readonly": True}, + "privacy_statement_uri": {"readonly": True}, + "eula": {"readonly": True}, + "artifact_tags": {"readonly": True}, } _attribute_map = { @@ -3874,77 +3921,28 @@ class SharedGalleryImage(PirSharedGalleryResource): } def __init__( - self, - *, - unique_id: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, - end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - recommended: Optional["_models.RecommendedMachineConfiguration"] = None, - disallowed: Optional["_models.Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - features: Optional[List["_models.GalleryImageFeature"]] = None, - purchase_plan: Optional["_models.ImagePurchasePlan"] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - privacy_statement_uri: Optional[str] = None, - eula: Optional[str] = None, - artifact_tags: Optional[Dict[str, str]] = None, - **kwargs: Any + self, *, unique_id: Optional[str] = None, disallowed: Optional["_models.Disallowed"] = None, **kwargs: Any ) -> None: """ :keyword unique_id: The unique id of this shared gallery. :paramtype unique_id: str - :keyword os_type: This property allows you to specify the type of the OS that is included in - the disk when creating a VM from a managed image. Possible values are: **Windows,** **Linux.**. - Known values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemTypes - :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized" - and "Specialized". - :paramtype os_state: str or ~azure.mgmt.compute.v2023_07_03.models.OperatingSystemStateTypes - :keyword end_of_life_date: The end of life date of the gallery image definition. This property - can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword identifier: This is the gallery image definition identifier. - :paramtype identifier: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageIdentifier - :keyword recommended: The properties describe the recommended machine configuration for this - Image Definition. These properties are updatable. - :paramtype recommended: ~azure.mgmt.compute.v2023_07_03.models.RecommendedMachineConfiguration :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2023_07_03.models.Disallowed - :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Known values are: "V1" and "V2". - :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2023_07_03.models.HyperVGeneration - :keyword features: A list of gallery image features. - :paramtype features: list[~azure.mgmt.compute.v2023_07_03.models.GalleryImageFeature] - :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by - marketplace images. - :paramtype purchase_plan: ~azure.mgmt.compute.v2023_07_03.models.ImagePurchasePlan - :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values - are: "x64" and "Arm64". - :paramtype architecture: str or ~azure.mgmt.compute.v2023_07_03.models.Architecture - :keyword privacy_statement_uri: Privacy statement uri for the current community gallery image. - :paramtype privacy_statement_uri: str - :keyword eula: End-user license agreement for the current community gallery image. - :paramtype eula: str - :keyword artifact_tags: The artifact tags of a shared gallery resource. - :paramtype artifact_tags: dict[str, str] """ super().__init__(unique_id=unique_id, **kwargs) - self.os_type = os_type - self.os_state = os_state - self.end_of_life_date = end_of_life_date - self.identifier = identifier - self.recommended = recommended + self.os_type = None + self.os_state = None + self.end_of_life_date = None + self.identifier = None + self.recommended = None self.disallowed = disallowed - self.hyper_v_generation = hyper_v_generation - self.features = features - self.purchase_plan = purchase_plan - self.architecture = architecture - self.privacy_statement_uri = privacy_statement_uri - self.eula = eula - self.artifact_tags = artifact_tags + self.hyper_v_generation = None + self.features = None + self.purchase_plan = None + self.architecture = None + self.privacy_statement_uri = None + self.eula = None + self.artifact_tags = None class SharedGalleryImageList(_serialization.Model): @@ -4013,6 +4011,11 @@ class SharedGalleryImageVersion(PirSharedGalleryResource): _validation = { "name": {"readonly": True}, "location": {"readonly": True}, + "published_date": {"readonly": True}, + "end_of_life_date": {"readonly": True}, + "exclude_from_latest": {"readonly": True}, + "storage_profile": {"readonly": True}, + "artifact_tags": {"readonly": True}, } _attribute_map = { @@ -4026,41 +4029,17 @@ class SharedGalleryImageVersion(PirSharedGalleryResource): "artifact_tags": {"key": "properties.artifactTags", "type": "{str}"}, } - def __init__( - self, - *, - unique_id: Optional[str] = None, - published_date: Optional[datetime.datetime] = None, - end_of_life_date: Optional[datetime.datetime] = None, - exclude_from_latest: Optional[bool] = None, - storage_profile: Optional["_models.SharedGalleryImageVersionStorageProfile"] = None, - artifact_tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, unique_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword unique_id: The unique id of this shared gallery. :paramtype unique_id: str - :keyword published_date: The published date of the gallery image version Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype published_date: ~datetime.datetime - :keyword end_of_life_date: The end of life date of the gallery image version Definition. This - property can be used for decommissioning purposes. This property is updatable. - :paramtype end_of_life_date: ~datetime.datetime - :keyword exclude_from_latest: If set to true, Virtual Machines deployed from the latest version - of the Image Definition won't use this Image Version. - :paramtype exclude_from_latest: bool - :keyword storage_profile: Describes the storage profile of the image version. - :paramtype storage_profile: - ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersionStorageProfile - :keyword artifact_tags: The artifact tags of a shared gallery resource. - :paramtype artifact_tags: dict[str, str] """ super().__init__(unique_id=unique_id, **kwargs) - self.published_date = published_date - self.end_of_life_date = end_of_life_date - self.exclude_from_latest = exclude_from_latest - self.storage_profile = storage_profile - self.artifact_tags = artifact_tags + self.published_date = None + self.end_of_life_date = None + self.exclude_from_latest = None + self.storage_profile = None + self.artifact_tags = None class SharedGalleryImageVersionList(_serialization.Model): @@ -4068,10 +4047,9 @@ class SharedGalleryImageVersionList(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar value: A list of shared gallery images versions. Required. + :ivar value: The SharedGalleryImageVersion items on this page. Required. :vartype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] - :ivar next_link: The uri to fetch the next page of shared gallery image versions. Call - ListNext() with this to fetch the next page of shared gallery image versions. + :ivar next_link: The link to the next page of items. :vartype next_link: str """ @@ -4088,10 +4066,9 @@ def __init__( self, *, value: List["_models.SharedGalleryImageVersion"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: A list of shared gallery images versions. Required. + :keyword value: The SharedGalleryImageVersion items on this page. Required. :paramtype value: list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] - :keyword next_link: The uri to fetch the next page of shared gallery image versions. Call - ListNext() with this to fetch the next page of shared gallery image versions. + :keyword next_link: The link to the next page of items. :paramtype next_link: str """ super().__init__(**kwargs) @@ -4102,6 +4079,8 @@ def __init__( class SharedGalleryImageVersionStorageProfile(_serialization.Model): """This is the storage profile of a Gallery Image Version. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar os_disk_image: This is the OS disk image. :vartype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryOSDiskImage :ivar data_disk_images: A list of data disk images. @@ -4109,28 +4088,21 @@ class SharedGalleryImageVersionStorageProfile(_serialization.Model): list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryDataDiskImage] """ + _validation = { + "os_disk_image": {"readonly": True}, + "data_disk_images": {"readonly": True}, + } + _attribute_map = { "os_disk_image": {"key": "osDiskImage", "type": "SharedGalleryOSDiskImage"}, "data_disk_images": {"key": "dataDiskImages", "type": "[SharedGalleryDataDiskImage]"}, } - def __init__( - self, - *, - os_disk_image: Optional["_models.SharedGalleryOSDiskImage"] = None, - data_disk_images: Optional[List["_models.SharedGalleryDataDiskImage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryOSDiskImage - :keyword data_disk_images: A list of data disk images. - :paramtype data_disk_images: - list[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryDataDiskImage] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.os_disk_image = os_disk_image - self.data_disk_images = data_disk_images + self.os_disk_image = None + self.data_disk_images = None class SharedGalleryList(_serialization.Model): @@ -4405,6 +4377,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.v2023_07_03.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.v2023_07_03.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.v2023_07_03.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.v2023_07_03.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/azure/mgmt/compute/v2023_07_03/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/__init__.py index 139d983a5840..79f57c74bf6a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/__init__.py @@ -13,17 +13,17 @@ from ._patch import * # pylint: disable=unused-wildcard-import from ._operations import GalleriesOperations # type: ignore -from ._operations import GalleryImagesOperations # type: ignore -from ._operations import GalleryImageVersionsOperations # type: ignore -from ._operations import GalleryApplicationsOperations # type: ignore -from ._operations import GalleryApplicationVersionsOperations # type: ignore -from ._operations import GallerySharingProfileOperations # type: ignore -from ._operations import SharedGalleriesOperations # type: ignore -from ._operations import SharedGalleryImagesOperations # type: ignore -from ._operations import SharedGalleryImageVersionsOperations # type: ignore from ._operations import CommunityGalleriesOperations # type: ignore from ._operations import CommunityGalleryImagesOperations # type: ignore from ._operations import CommunityGalleryImageVersionsOperations # type: ignore +from ._operations import SharedGalleriesOperations # type: ignore +from ._operations import SharedGalleryImagesOperations # type: ignore +from ._operations import SharedGalleryImageVersionsOperations # type: ignore +from ._operations import GalleryApplicationsOperations # type: ignore +from ._operations import GalleryApplicationVersionsOperations # type: ignore +from ._operations import GalleryImagesOperations # type: ignore +from ._operations import GalleryImageVersionsOperations # type: ignore +from ._operations import GallerySharingProfileOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -31,17 +31,17 @@ __all__ = [ "GalleriesOperations", - "GalleryImagesOperations", - "GalleryImageVersionsOperations", - "GalleryApplicationsOperations", - "GalleryApplicationVersionsOperations", - "GallerySharingProfileOperations", - "SharedGalleriesOperations", - "SharedGalleryImagesOperations", - "SharedGalleryImageVersionsOperations", "CommunityGalleriesOperations", "CommunityGalleryImagesOperations", "CommunityGalleryImageVersionsOperations", + "SharedGalleriesOperations", + "SharedGalleryImagesOperations", + "SharedGalleryImageVersionsOperations", + "GalleryApplicationsOperations", + "GalleryApplicationVersionsOperations", + "GalleryImagesOperations", + "GalleryImageVersionsOperations", + "GallerySharingProfileOperations", ] __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/v2023_07_03/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_operations.py index b614a48c80d5..3b78c4f92bde 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2023_07_03/operations/_operations.py @@ -44,25 +44,17 @@ _SERIALIZER.client_side_validation = False -def build_galleries_create_or_update_request( - resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_galleries_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", "2023-07-03")) - 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/galleries/{galleryName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_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_galleries_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_galleries_update_request( - resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any +def build_galleries_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", "2023-07-03")) - 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/galleries/{galleryName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_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,11 +95,9 @@ def build_galleries_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_galleries_get_request( @@ -133,8 +121,10 @@ def build_galleries_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -153,13 +143,14 @@ def build_galleries_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_galleries_delete_request( +def build_galleries_create_or_update_request( resource_group_name: str, gallery_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", "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,8 +159,10 @@ def build_galleries_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } @@ -179,28 +172,34 @@ def build_galleries_delete_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_galleries_list_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any +def build_galleries_update_request( + resource_group_name: str, gallery_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", "2023-07-03")) + 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/galleries", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", ) # 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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -209,12 +208,16 @@ def build_galleries_list_by_resource_group_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_galleries_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_galleries_delete_request( + resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -222,9 +225,16 @@ def build_galleries_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/galleries") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", + ) # 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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -235,29 +245,27 @@ def build_galleries_list_request(subscription_id: str, **kwargs: Any) -> HttpReq # 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_gallery_images_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_community_galleries_get_request( + location: str, public_gallery_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", "2023-07-03")) - 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/galleries/{galleryName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -266,33 +274,29 @@ def build_gallery_images_create_or_update_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_images_update_request( - resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_community_gallery_images_list_request( # pylint: disable=name-too-long + location: str, public_gallery_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", "2023-07-03")) - 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/galleries/{galleryName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -301,15 +305,13 @@ def build_gallery_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_gallery_images_get_request( - resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_community_gallery_images_get_request( # pylint: disable=name-too-long + location: str, public_gallery_name: str, gallery_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 {}) @@ -320,12 +322,12 @@ def build_gallery_images_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } @@ -340,8 +342,8 @@ def build_gallery_images_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_images_delete_request( - resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_community_gallery_image_versions_list_request( # pylint: disable=name-too-long + location: str, public_gallery_name: str, gallery_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 {}) @@ -352,12 +354,12 @@ def build_gallery_images_delete_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } @@ -369,11 +371,16 @@ def build_gallery_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_gallery_images_list_by_gallery_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any +def build_community_gallery_image_versions_get_request( # pylint: disable=name-too-long + location: str, + public_gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -384,12 +391,14 @@ def build_gallery_images_list_by_gallery_request( # pylint: disable=name-too-lo # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -403,73 +412,60 @@ def build_gallery_images_list_by_gallery_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_image_versions_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, +def build_shared_galleries_list_request( + location: str, subscription_id: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = 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", "2023-07-03")) - 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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), - "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "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 _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if shared_to is not None: + _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "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_gallery_image_versions_update_request( # pylint: disable=name-too-long - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - subscription_id: str, - **kwargs: Any +def build_shared_galleries_get_request( + location: str, gallery_unique_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", "2023-07-03")) - 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/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), - "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -478,21 +474,17 @@ def build_gallery_image_versions_update_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_image_versions_get_request( - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, +def build_shared_gallery_images_list_request( + location: str, + gallery_unique_name: str, subscription_id: str, *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -504,22 +496,20 @@ def build_gallery_image_versions_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), - "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 shared_to is not None: + _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -527,13 +517,8 @@ def build_gallery_image_versions_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_image_versions_delete_request( # pylint: disable=name-too-long - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - subscription_id: str, - **kwargs: Any +def build_shared_gallery_images_get_request( + location: str, gallery_unique_name: str, gallery_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 {}) @@ -544,14 +529,13 @@ def build_gallery_image_versions_delete_request( # pylint: disable=name-too-lon # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), - "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -562,11 +546,17 @@ def build_gallery_image_versions_delete_request( # pylint: disable=name-too-lon # 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_gallery_image_versions_list_by_gallery_image_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_shared_gallery_image_versions_list_request( # pylint: disable=name-too-long + location: str, + gallery_unique_name: str, + gallery_image_name: str, + subscription_id: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -577,12 +567,12 @@ def build_gallery_image_versions_list_by_gallery_image_request( # pylint: disab # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } @@ -590,6 +580,8 @@ def build_gallery_image_versions_list_by_gallery_image_request( # pylint: disab # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if shared_to is not None: + _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -597,26 +589,31 @@ def build_gallery_image_versions_list_by_gallery_image_request( # pylint: disab return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_applications_create_or_update_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any +def build_shared_gallery_image_versions_get_request( # pylint: disable=name-too-long + location: str, + gallery_unique_name: str, + gallery_image_name: str, + gallery_image_version_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", "2023-07-03")) - 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/galleries/{galleryName}/applications/{galleryApplicationName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # 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"), - "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -625,33 +622,31 @@ def build_gallery_applications_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_gallery_applications_update_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any +def build_gallery_applications_list_by_gallery_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_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", "2023-07-03")) - 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/galleries/{galleryName}/applications/{galleryApplicationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -660,11 +655,9 @@ def build_gallery_applications_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_gallery_applications_get_request( @@ -682,8 +675,10 @@ def build_gallery_applications_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), } @@ -699,13 +694,14 @@ def build_gallery_applications_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_applications_delete_request( # pylint: disable=name-too-long +def build_gallery_applications_create_or_update_request( # pylint: disable=name-too-long resource_group_name: str, gallery_name: str, gallery_application_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", "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -714,8 +710,83 @@ def build_gallery_applications_delete_request( # pylint: disable=name-too-long "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", ) # 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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_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 + 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_gallery_applications_update_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, gallery_application_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", "2023-07-03")) + 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/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # 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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_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 + 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) + + +def build_gallery_applications_delete_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, gallery_application_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", "2023-07-03")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}", + ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), } @@ -731,8 +802,8 @@ def build_gallery_applications_delete_request( # pylint: disable=name-too-long return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_applications_list_by_gallery_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any +def build_gallery_application_versions_list_by_gallery_application_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -743,12 +814,15 @@ def build_gallery_applications_list_by_gallery_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -762,19 +836,20 @@ def build_gallery_applications_list_by_gallery_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_application_versions_create_or_update_request( # pylint: disable=name-too-long +def build_gallery_application_versions_get_request( # pylint: disable=name-too-long resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, subscription_id: str, + *, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = 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", "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -783,8 +858,10 @@ def build_gallery_application_versions_create_or_update_request( # pylint: disa "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), "galleryApplicationVersionName": _SERIALIZER.url( @@ -796,16 +873,16 @@ def build_gallery_application_versions_create_or_update_request( # pylint: disa # 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_gallery_application_versions_update_request( # pylint: disable=name-too-long +def build_gallery_application_versions_create_or_update_request( # pylint: disable=name-too-long resource_group_name: str, gallery_name: str, gallery_application_name: str, @@ -826,8 +903,10 @@ def build_gallery_application_versions_update_request( # pylint: disable=name-t "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), "galleryApplicationVersionName": _SERIALIZER.url( @@ -845,23 +924,22 @@ def build_gallery_application_versions_update_request( # pylint: disable=name-t _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_gallery_application_versions_get_request( # pylint: disable=name-too-long +def build_gallery_application_versions_update_request( # pylint: disable=name-too-long resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, subscription_id: str, - *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = 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", "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -870,8 +948,10 @@ def build_gallery_application_versions_get_request( # pylint: disable=name-too- "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), "galleryApplicationVersionName": _SERIALIZER.url( @@ -882,14 +962,14 @@ def build_gallery_application_versions_get_request( # pylint: disable=name-too- _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_gallery_application_versions_delete_request( # pylint: disable=name-too-long @@ -912,8 +992,10 @@ def build_gallery_application_versions_delete_request( # pylint: disable=name-t "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), "galleryApplicationVersionName": _SERIALIZER.url( @@ -932,8 +1014,8 @@ def build_gallery_application_versions_delete_request( # pylint: disable=name-t return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_application_versions_list_by_gallery_application_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any +def build_gallery_images_list_by_gallery_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -944,13 +1026,14 @@ def build_gallery_application_versions_list_by_gallery_application_request( # p # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), - "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -964,25 +1047,27 @@ def build_gallery_application_versions_list_by_gallery_application_request( # p return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_gallery_sharing_profile_update_request( # pylint: disable=name-too-long - resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any +def build_gallery_images_get_request( + resource_group_name: str, gallery_name: str, gallery_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", "2023-07-03")) - 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/galleries/{galleryName}/share", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", ) # 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 + ), "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -991,67 +1076,70 @@ def build_gallery_sharing_profile_update_request( # pylint: disable=name-too-lo _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_shared_galleries_list_request( - location: str, - subscription_id: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, - **kwargs: Any +def build_gallery_images_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, gallery_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", "2023-07-03")) + 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}/sharedGalleries", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_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 shared_to is not None: - _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "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_shared_galleries_get_request( - location: str, gallery_unique_name: str, subscription_id: str, **kwargs: Any +def build_gallery_images_update_request( + resource_group_name: str, gallery_name: str, gallery_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", "2023-07-03")) + 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}/sharedGalleries/{galleryUniqueName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1060,18 +1148,15 @@ def build_shared_galleries_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_shared_gallery_images_list_request( - location: str, - gallery_unique_name: str, - subscription_id: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, - **kwargs: Any +def build_gallery_images_delete_request( + resource_group_name: str, gallery_name: str, gallery_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 {}) @@ -1082,29 +1167,30 @@ def build_shared_gallery_images_list_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_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 shared_to is not None: - _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str") # 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_shared_gallery_images_get_request( - location: str, gallery_unique_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_gallery_image_versions_list_by_gallery_image_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_name: str, gallery_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 {}) @@ -1115,12 +1201,14 @@ def build_shared_gallery_images_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), } @@ -1135,13 +1223,14 @@ def build_shared_gallery_images_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_shared_gallery_image_versions_list_request( # pylint: disable=name-too-long - location: str, - gallery_unique_name: str, +def build_gallery_image_versions_get_request( + resource_group_name: str, + gallery_name: str, gallery_image_name: str, + gallery_image_version_name: str, subscription_id: str, *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1153,21 +1242,24 @@ def build_shared_gallery_image_versions_list_request( # pylint: disable=name-to # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if shared_to is not None: - _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1175,9 +1267,9 @@ def build_shared_gallery_image_versions_list_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_shared_gallery_image_versions_get_request( # pylint: disable=name-too-long - location: str, - gallery_unique_name: str, +def build_gallery_image_versions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, subscription_id: str, @@ -1187,17 +1279,20 @@ def build_shared_gallery_image_versions_get_request( # pylint: disable=name-too _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-03")) + 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}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } @@ -1208,29 +1303,41 @@ def build_shared_gallery_image_versions_get_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_community_galleries_get_request( - location: str, public_gallery_name: str, subscription_id: str, **kwargs: Any +def build_gallery_image_versions_update_request( # pylint: disable=name-too-long + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_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", "2023-07-03")) + 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}/communityGalleries/{publicGalleryName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), + "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), + "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1239,13 +1346,20 @@ def build_community_galleries_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_community_gallery_images_get_request( # pylint: disable=name-too-long - location: str, public_gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_gallery_image_versions_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1256,80 +1370,14 @@ def build_community_gallery_images_get_request( # pylint: disable=name-too-long # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_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_community_gallery_images_list_request( # pylint: disable=name-too-long - location: str, public_gallery_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", "2023-07-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_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_community_gallery_image_versions_get_request( # pylint: disable=name-too-long - location: str, - public_gallery_name: str, - gallery_image_name: str, - gallery_image_version_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", "2023-07-03")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"), "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"), } @@ -1342,28 +1390,30 @@ def build_community_gallery_image_versions_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_community_gallery_image_versions_list_request( # pylint: disable=name-too-long - location: str, public_gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any +def build_gallery_sharing_profile_update_request( # pylint: disable=name-too-long + resource_group_name: str, gallery_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", "2023-07-03")) + 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}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str"), - "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"), - "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_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 + ), + "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1372,9 +1422,11 @@ def build_community_gallery_image_versions_list_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) class GalleriesOperations: @@ -1397,9 +1449,20 @@ 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, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Gallery"]: + """List galleries under a subscription. + + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :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 "2023-07-03")) + cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1408,187 +1471,212 @@ 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) - 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(gallery, (IOBase, bytes)): - _content = gallery - else: - _json = self._serialize.body(gallery, "Gallery") - - _request = build_galleries_create_or_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_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 + def prepare_request(next_link=None): + if not next_link: - if response.status_code not in [200, 201, 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) + _request = build_galleries_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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("GalleryList", 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 begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: _models.Gallery, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Gallery]: - """Create or update a Shared Image Gallery. + _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 gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: ~azure.mgmt.compute.v2023_07_03.models.Gallery - :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 Gallery or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Gallery]: - """Create or update a Shared Image Gallery. + return pipeline_response - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. - Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. - Required. - :type gallery: 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 Gallery or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Gallery]: - """Create or update a Shared Image Gallery. + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gallery"]: + """List galleries under a resource group. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. - :type gallery_name: str - :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Is - either a Gallery type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2023_07_03.models.Gallery or IO[bytes] - :return: An instance of LROPoller that returns either Gallery or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :type resource_group_name: str + :return: An iterator like instance of either Gallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Gallery] = 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, - gallery_name=gallery_name, - gallery=gallery, - 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.GalleryList] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Gallery", pipeline_response.http_response) + 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_galleries_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("GalleryList", 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.Gallery].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.Gallery]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response - def _update_initial( + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + @distributed_trace + def get( self, resource_group_name: str, gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], + *, + select: Optional[Union[str, _models.SelectPermissions]] = None, + expand: Optional[Union[str, _models.GalleryExpandParams]] = None, **kwargs: Any + ) -> _models.Gallery: + """Retrieves information about a Shared Image Gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :keyword select: The select expression to apply on the operation. "Permissions" Default value + is None. + :paramtype select: str or ~azure.mgmt.compute.v2023_07_03.models.SelectPermissions + :keyword expand: The expand query option to apply on the operation. "SharingProfile/Groups" + Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExpandParams + :return: Gallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.Gallery + :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 "2023-07-03")) + cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) + + _request = build_galleries_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + subscription_id=self._config.subscription_id, + select=select, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Gallery", 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, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1611,9 +1699,9 @@ def _update_initial( if isinstance(gallery, (IOBase, bytes)): _content = gallery else: - _json = self._serialize.body(gallery, "GalleryUpdate") + _json = self._serialize.body(gallery, "Gallery") - _request = build_galleries_update_request( + _request = build_galleries_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, @@ -1634,41 +1722,50 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, gallery_name: str, - gallery: _models.GalleryUpdate, + gallery: _models.Gallery, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: - """Update a Shared Image Gallery. + """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. - :type gallery: ~azure.mgmt.compute.v2023_07_03.models.GalleryUpdate + :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. + Required. + :type gallery: ~azure.mgmt.compute.v2023_07_03.models.Gallery :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1678,7 +1775,7 @@ def begin_update( """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, gallery_name: str, @@ -1687,15 +1784,15 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: - """Update a Shared Image Gallery. + """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. + :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. + Required. :type gallery: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1706,24 +1803,19 @@ def begin_update( """ @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery: Union[_models.GalleryUpdate, IO[bytes]], - **kwargs: Any + def begin_create_or_update( + self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Gallery]: - """Update a Shared Image Gallery. + """Create or update a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets - and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery: Parameters supplied to the update Shared Image Gallery operation. Is either a - GalleryUpdate type or a IO[bytes] type. Required. - :type gallery: ~azure.mgmt.compute.v2023_07_03.models.GalleryUpdate or IO[bytes] + :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Is + either a Gallery type or a IO[bytes] type. Required. + :type gallery: ~azure.mgmt.compute.v2023_07_03.models.Gallery or IO[bytes] :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: @@ -1738,7 +1830,7 @@ def begin_update( 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, gallery_name=gallery_name, gallery=gallery, @@ -1759,7 +1851,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: @@ -1775,32 +1869,13 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( + def _update_initial( self, resource_group_name: str, gallery_name: str, - *, - select: Optional[Union[str, _models.SelectPermissions]] = None, - expand: Optional[Union[str, _models.GalleryExpandParams]] = None, + gallery: Union[_models.GalleryUpdate, IO[bytes]], **kwargs: Any - ) -> _models.Gallery: - """Retrieves information about a Shared Image Gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. Required. - :type gallery_name: str - :keyword select: The select expression to apply on the operation. "Permissions" Default value - is None. - :paramtype select: str or ~azure.mgmt.compute.v2023_07_03.models.SelectPermissions - :keyword expand: The expand query option to apply on the operation. "SharingProfile/Groups" - Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.GalleryExpandParams - :return: Gallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.Gallery - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1809,42 +1884,188 @@ 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 "2023-07-03")) - cls: ClsType[_models.Gallery] = 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_galleries_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - subscription_id=self._config.subscription_id, - select=select, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery, (IOBase, bytes)): + _content = gallery + else: + _json = self._serialize.body(gallery, "GalleryUpdate") + + _request = build_galleries_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Gallery", 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 begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: _models.GalleryUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Gallery]: + """Update a Shared Image Gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. + :type gallery: ~azure.mgmt.compute.v2023_07_03.models.GalleryUpdate + :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 Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Gallery]: + """Update a Shared Image Gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. + :type gallery: 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 Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery: Union[_models.GalleryUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Gallery]: + """Update a Shared Image Gallery. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery: Parameters supplied to the update Shared Image Gallery operation. Is either a + GalleryUpdate type or a IO[bytes] type. Required. + :type gallery: ~azure.mgmt.compute.v2023_07_03.models.GalleryUpdate or IO[bytes] + :return: An instance of LROPoller that returns either Gallery or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :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 "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Gallery] = 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, + gallery_name=gallery_name, + gallery=gallery, + 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("Gallery", 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.Gallery].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Gallery]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + def _delete_initial(self, resource_group_name: str, gallery_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1884,12 +2105,18 @@ def _delete_initial(self, resource_group_name: str, gallery_name: str, **kwargs: except (StreamConsumedError, StreamClosedError): pass 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) + + 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 @@ -1897,9 +2124,10 @@ def _delete_initial(self, resource_group_name: str, gallery_name: str, **kwargs: def begin_delete(self, resource_group_name: str, gallery_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a Shared Image Gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery to be deleted. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] @@ -1931,7 +2159,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: @@ -1945,22 +2175,39 @@ 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 CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`community_galleries` 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.Gallery"]: - """List galleries under a resource group. + def get(self, location: str, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: + """Get a community gallery by gallery public name. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :return: An iterator like instance of either Gallery or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :return: CommunityGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGallery :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 "2023-07-03")) - cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1969,72 +2216,81 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite } 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_galleries_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) + cls: ClsType[_models.CommunityGallery] = 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_community_galleries_get_request( + location=location, + public_gallery_name=public_gallery_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("GalleryList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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("CommunityGallery", 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 + + +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`community_gallery_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(self, **kwargs: Any) -> Iterable["_models.Gallery"]: - """List galleries under a subscription. + def list(self, location: str, public_gallery_name: str, **kwargs: Any) -> Iterable["_models.CommunityGalleryImage"]: + """List community gallery images inside a gallery. - :return: An iterator like instance of either Gallery or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.Gallery] + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :return: An iterator like instance of either CommunityGalleryImage or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] :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 "2023-07-03")) - cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) + cls: ClsType[_models.CommunityGalleryImageList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2047,7 +2303,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Gallery"]: def prepare_request(next_link=None): if not next_link: - _request = build_galleries_list_request( + _request = build_community_gallery_images_list_request( + location=location, + public_gallery_name=public_gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2073,7 +2331,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryList", pipeline_response) + deserialized = self._deserialize("CommunityGalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2090,21 +2348,82 @@ 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) + @distributed_trace + def get( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.CommunityGalleryImage: + """Get a community gallery image. -class GalleryImagesOperations: + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :return: CommunityGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage + :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 "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) + + _request = build_community_gallery_images_get_request( + location=location, + public_gallery_name=public_gallery_name, + gallery_image_name=gallery_image_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CommunityGalleryImage", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CommunityGalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`gallery_images` attribute. + :attr:`community_gallery_image_versions` attribute. """ models = _models @@ -2117,14 +2436,120 @@ 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( + @distributed_trace + def list( + self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> Iterable["_models.CommunityGalleryImageVersion"]: + """List community gallery image versions inside an image. + + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :return: An iterator like instance of either CommunityGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] + :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 "2023-07-03")) + cls: ClsType[_models.CommunityGalleryImageVersionList] = 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_community_gallery_image_versions_list_request( + location=location, + public_gallery_name=public_gallery_name, + gallery_image_name=gallery_image_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("CommunityGalleryImageVersionList", 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) + 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) + + @distributed_trace + def get( self, - resource_group_name: str, - gallery_name: str, + location: str, + public_gallery_name: str, gallery_image_name: str, - gallery_image: Union[_models.GalleryImage, IO[bytes]], + gallery_image_version_name: str, **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.CommunityGalleryImageVersion: + """Get a community gallery image version. + + :param location: The name of Azure region. Required. + :type location: str + :param public_gallery_name: The public name of the community gallery. Required. + :type public_gallery_name: str + :param gallery_image_name: The name of the community gallery image definition. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the community gallery image version. Needs to + follow semantic version name pattern: The allowed characters are digit and period. Digits must + be within the range of a 32-bit integer. Format: :code:``.\\ + :code:``.\\ :code:``. Required. + :type gallery_image_version_name: str + :return: CommunityGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2133,210 +2558,160 @@ 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 "2023-07-03")) - 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(gallery_image, (IOBase, bytes)): - _content = gallery_image - else: - _json = self._serialize.body(gallery_image, "GalleryImage") + cls: ClsType[_models.CommunityGalleryImageVersion] = kwargs.pop("cls", None) - _request = build_gallery_images_create_or_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_community_gallery_image_versions_get_request( + location=location, + public_gallery_name=public_gallery_name, gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("CommunityGalleryImageVersion", 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, - gallery_name: str, - gallery_image_name: str, - gallery_image: _models.GalleryImage, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. - Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage - :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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. - Required. - :type gallery_image: 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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :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, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImage, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Create or update a gallery image definition. + def list( + self, location: str, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any + ) -> Iterable["_models.SharedGallery"]: + """List shared galleries by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be created. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be created or updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the create or update gallery image operation. Is - either a GalleryImage type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage or IO[bytes] - :return: An instance of LROPoller that returns either GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + :param location: The name of Azure region. Required. + :type location: str + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGallery or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImage] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image=gallery_image, - 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.SharedGalleryList] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) + 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_shared_galleries_list_request( + location=location, + subscription_id=self._config.subscription_id, + shared_to=shared_to, + 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("SharedGalleryList", 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.GalleryImage].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.GalleryImage]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response - def _update_initial( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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) + + @distributed_trace + def get(self, location: str, gallery_unique_name: str, **kwargs: Any) -> _models.SharedGallery: + """Get a shared gallery by subscription id or tenant id. + + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :return: SharedGallery or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGallery + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2345,37 +2720,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 "2023-07-03")) - 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(gallery_image, (IOBase, bytes)): - _content = gallery_image - else: - _json = self._serialize.body(gallery_image, "GalleryImageUpdate") + cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) - _request = build_gallery_images_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, + _request = build_shared_galleries_get_request( + location=location, + gallery_unique_name=gallery_unique_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 ) @@ -2383,177 +2744,145 @@ 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("SharedGallery", 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, - gallery_name: str, - gallery_image_name: str, - gallery_image: _models.GalleryImageUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate - :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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Update a gallery image definition. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Required. - :type gallery_image: 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 GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] - :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_update( + def list( self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], + location: str, + gallery_unique_name: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any - ) -> LROPoller[_models.GalleryImage]: - """Update a gallery image definition. + ) -> Iterable["_models.SharedGalleryImage"]: + """List shared gallery images by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be updated. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be updated. The allowed - characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The - maximum length is 80 characters. Required. - :type gallery_image_name: str - :param gallery_image: Parameters supplied to the update gallery image operation. Is either a - GalleryImageUpdate type or a IO[bytes] type. Required. - :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate or IO[bytes] - :return: An instance of LROPoller that returns either GalleryImage or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImage] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image=gallery_image, - 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.SharedGalleryImageList] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) + 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_shared_gallery_images_list_request( + location=location, + gallery_unique_name=gallery_unique_name, + subscription_id=self._config.subscription_id, + shared_to=shared_to, + 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("SharedGalleryImageList", 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.GalleryImage].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.GalleryImage]( - 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) + 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) @distributed_trace def get( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.GalleryImage: - """Retrieves information about a gallery image definition. + self, location: str, gallery_unique_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.SharedGalleryImage: + """Get a shared gallery image by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery from which the Image Definitions are - to be retrieved. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. :type gallery_image_name: str - :return: GalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage + :return: SharedGalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2568,11 +2897,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 "2023-07-03")) - cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) + cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) - _request = build_gallery_images_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_gallery_images_get_request( + location=location, + gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -2590,144 +2919,70 @@ def get( 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) - deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) + deserialized = self._deserialize("SharedGalleryImage", 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, gallery_name: str, gallery_image_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 "2023-07-03")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - _request = build_gallery_images_delete_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. + """ - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + models = _models - 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 + 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, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Delete a gallery image. + def list( + self, + location: str, + gallery_unique_name: str, + gallery_image_name: str, + *, + shared_to: Optional[Union[str, _models.SharedToValues]] = None, + **kwargs: Any + ) -> Iterable["_models.SharedGalleryImageVersion"]: + """List shared gallery image versions by subscription id or tenant id. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to - be deleted. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition to be deleted. Required. + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. :type gallery_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) - 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, - gallery_name=gallery_name, - gallery_image_name=gallery_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) - - 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_by_gallery( - self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImage"]: - """List gallery image definitions in a gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery from which Image Definitions are to - be listed. Required. - :type gallery_name: str - :return: An iterator like instance of either GalleryImage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] + :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing + listing operations. "tenant" Default value is None. + :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues + :return: An iterator like instance of either SharedGalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] :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 "2023-07-03")) - cls: ClsType[_models.GalleryImageList] = kwargs.pop("cls", None) + cls: ClsType[_models.SharedGalleryImageVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2740,10 +2995,12 @@ def list_by_gallery( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_images_list_by_gallery_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_gallery_image_versions_list_request( + location=location, + gallery_unique_name=gallery_unique_name, + gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, + shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, @@ -2768,7 +3025,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageList", pipeline_response) + deserialized = self._deserialize("SharedGalleryImageVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2785,42 +3042,40 @@ 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 GalleryImageVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`gallery_image_versions` 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( + @distributed_trace + def get( self, - resource_group_name: str, - gallery_name: str, + location: str, + gallery_unique_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.SharedGalleryImageVersion: + """Get a shared gallery image version by subscription id or tenant id. + + :param location: The name of Azure region. Required. + :type location: str + :param gallery_unique_name: The unique name of the Shared Gallery. Required. + :type gallery_unique_name: str + :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image + Versions are to be listed. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be created. Needs + to follow semantic version name pattern: The allowed characters are digit and period. Digits + must be within the range of a 32-bit integer. Format: :code:``.\\ + :code:``.\\ :code:``. Required. + :type gallery_image_version_name: str + :return: SharedGalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2829,230 +3084,216 @@ 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 "2023-07-03")) - 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(gallery_image_version, (IOBase, bytes)): - _content = gallery_image_version - else: - _json = self._serialize.body(gallery_image_version, "GalleryImageVersion") + cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) - _request = build_gallery_image_versions_create_or_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, + _request = build_shared_gallery_image_versions_get_request( + location=location, + gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_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, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("SharedGalleryImageVersion", 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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: _models.GalleryImageVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion - :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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def begin_create_or_update( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. + """ - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Required. - :type gallery_image_version: 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 GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] - :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, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Create or update a gallery image version. + def list_by_gallery( + self, resource_group_name: str, gallery_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryApplication"]: + """List gallery Application Definitions in a gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be created. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the create or update gallery image version - operation. Is either a GalleryImageVersion type or a IO[bytes] type. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion or - IO[bytes] - :return: An instance of LROPoller that returns either GalleryImageVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :return: An iterator like instance of either GalleryApplication or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImageVersion] = 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, - gallery_image_version=gallery_image_version, - 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.GalleryApplicationList] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) + 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_gallery_applications_list_by_gallery_request( + resource_group_name=resource_group_name, + gallery_name=gallery_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("GalleryApplicationList", 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.GalleryImageVersion].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.GalleryImageVersion]( - 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) + 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) + + @distributed_trace + def get( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> _models.GalleryApplication: + """Retrieves information about a gallery Application Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :return: GalleryApplication or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication + :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 "2023-07-03")) + cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) + + _request = build_gallery_applications_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_application_name=gallery_application_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryApplication", 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, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3073,16 +3314,15 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(gallery_image_version, (IOBase, bytes)): - _content = gallery_image_version + if isinstance(gallery_application, (IOBase, bytes)): + _content = gallery_application else: - _json = self._serialize.body(gallery_image_version, "GalleryImageVersionUpdate") + _json = self._serialize.body(gallery_application, "GalleryApplication") - _request = build_gallery_image_versions_update_request( + _request = build_gallery_applications_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, + gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3101,134 +3341,125 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: _models.GalleryImageVersionUpdate, + gallery_application_name: str, + gallery_application: _models.GalleryApplication, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. + ) -> LROPoller[_models.GalleryApplication]: + """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate + :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication :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 GalleryImageVersion or the result of + :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update( + def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: IO[bytes], + gallery_application_name: str, + gallery_application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. + ) -> LROPoller[_models.GalleryApplication]: + """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. - :type gallery_image_version: IO[bytes] + :type gallery_application: 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 GalleryImageVersion or the result of + :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update( + def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplication, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GalleryImageVersion]: - """Update a gallery image version. + ) -> LROPoller[_models.GalleryApplication]: + """Create or update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - is to be updated. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be updated. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :param gallery_image_version: Parameters supplied to the update gallery image version - operation. Is either a GalleryImageVersionUpdate type or a IO[bytes] type. Required. - :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate - or IO[bytes] - :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the create or update gallery Application + operation. Is either a GalleryApplication type or a IO[bytes] type. Required. + :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication or + IO[bytes] + :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3236,17 +3467,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplication] = 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, gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, - gallery_image_version=gallery_image_version, + gallery_application_name=gallery_application_name, + gallery_application=gallery_application, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3258,7 +3488,7 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) + deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -3270,98 +3500,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.GalleryImageVersion].from_continuation_token( + return LROPoller[_models.GalleryApplication].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GalleryImageVersion]( + return LROPoller[_models.GalleryApplication]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( - self, - resource_group_name: str, - gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, - *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, - **kwargs: Any - ) -> _models.GalleryImageVersion: - """Retrieves information about a gallery image version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. - :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - resides. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be retrieved. - Required. - :type gallery_image_version_name: str - :keyword expand: The expand expression to apply on the operation. Known values are: - "ReplicationStatus" and "UefiSettings". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes - :return: GalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion - :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 "2023-07-03")) - cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) - - _request = build_gallery_image_versions_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_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("GalleryImageVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( + def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3372,19 +3526,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 "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_gallery_image_versions_delete_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_application, (IOBase, bytes)): + _content = gallery_application + else: + _json = self._serialize.body(gallery_application, "GalleryApplicationUpdate") + + _request = build_gallery_applications_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, + gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -3398,76 +3563,279 @@ 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): pass 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) + + 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( + @overload + def begin_update( self, resource_group_name: str, gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, + gallery_application_name: str, + gallery_application: _models.GalleryApplicationUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Delete a gallery image version. + ) -> LROPoller[_models.GalleryApplication]: + """Update a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the gallery image definition in which the Image Version - resides. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be deleted. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the update gallery Application operation. Required. - :type gallery_image_version_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationUpdate + :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 GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] :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 "2023-07-03")) - 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, - gallery_name=gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_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, + gallery_name: str, + gallery_application_name: str, + gallery_application: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryApplication]: + """Update a gallery Application Definition. - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the update gallery Application operation. + Required. + :type gallery_application: 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 GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.GalleryApplication]: + """Update a gallery Application Definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application: Parameters supplied to the update gallery Application operation. Is + either a GalleryApplicationUpdate type or a IO[bytes] type. Required. + :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationUpdate or + IO[bytes] + :return: An instance of LROPoller that returns either GalleryApplication or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + :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 "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryApplication] = 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, + gallery_name=gallery_name, + gallery_application_name=gallery_application_name, + gallery_application=gallery_application, + 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("GalleryApplication", 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.GalleryApplication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GalleryApplication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, gallery_name: str, gallery_application_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 "2023-07-03")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_gallery_applications_delete_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_application_name=gallery_application_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a gallery Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_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 "2023-07-03")) + 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, + gallery_name=gallery_name, + gallery_application_name=gallery_application_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: @@ -3481,30 +3849,52 @@ 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 GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`gallery_application_versions` 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_gallery_image( - self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersion"]: - """List gallery image versions in a gallery image definition. + def list_by_gallery_application( + self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryApplicationVersion"]: + """List gallery Application Versions in a gallery Application Definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery in which the Image Definition - resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_image_name: The name of the Shared Image Gallery Image Definition from which the - Image Versions are to be listed. Required. - :type gallery_image_name: str - :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :return: An iterator like instance of either GalleryApplicationVersion or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :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 "2023-07-03")) - cls: ClsType[_models.GalleryImageVersionList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplicationVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3517,10 +3907,10 @@ def list_by_gallery_image( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_image_versions_list_by_gallery_image_request( + _request = build_gallery_application_versions_list_by_gallery_application_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_image_name=gallery_image_name, + gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -3546,7 +3936,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryImageVersionList", pipeline_response) + deserialized = self._deserialize("GalleryApplicationVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -3563,39 +3953,97 @@ 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) + @distributed_trace + def get( + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + *, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, + **kwargs: Any + ) -> _models.GalleryApplicationVersion: + """Retrieves information about a gallery Application Version. -class GalleryApplicationsOperations: - """ - .. 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. + :type gallery_application_name: str + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :keyword expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes + :return: GalleryApplicationVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion + :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.v2023_07_03.ComputeManagementClient`'s - :attr:`gallery_applications` 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 "2023-07-03")) + cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) - 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") + _request = build_gallery_application_versions_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryApplicationVersion", 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, gallery_name: str, gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], + gallery_application_version_name: str, + gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3616,15 +4064,16 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(gallery_application, (IOBase, bytes)): - _content = gallery_application + if isinstance(gallery_application_version, (IOBase, bytes)): + _content = gallery_application_version else: - _json = self._serialize.body(gallery_application, "GalleryApplication") + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") - _request = build_gallery_applications_create_or_update_request( + _request = build_gallery_application_versions_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3649,12 +4098,21 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 @@ -3664,32 +4122,36 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: _models.GalleryApplication, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersion, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or update gallery Application - operation. Required. - :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the create or update gallery + Application Version operation. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion :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 GalleryApplication or the result of - cls(response) + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3699,32 +4161,35 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: IO[bytes], + gallery_application_version_name: str, + gallery_application_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or update gallery Application - operation. Required. - :type gallery_application: IO[bytes] + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the create or update gallery + Application Version operation. Required. + :type gallery_application_version: 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 GalleryApplication or the result of - cls(response) + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3734,28 +4199,32 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: Union[_models.GalleryApplication, IO[bytes]], + gallery_application_version_name: str, + gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Create or update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Create or update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be created. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be created - or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods - allowed in the middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the create or update gallery Application - operation. Is either a GalleryApplication type or a IO[bytes] type. Required. - :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication or - IO[bytes] - :return: An instance of LROPoller that returns either GalleryApplication or the result of - cls(response) + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the create or update gallery + Application Version operation. Is either a GalleryApplicationVersion type or a IO[bytes] type. + Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion or IO[bytes] + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3763,7 +4232,7 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplicationVersion] = 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) @@ -3772,7 +4241,8 @@ def begin_create_or_update( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, - gallery_application=gallery_application, + gallery_application_version_name=gallery_application_version_name, + gallery_application_version=gallery_application_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -3784,25 +4254,27 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) + deserialized = self._deserialize("GalleryApplicationVersion", 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.GalleryApplication].from_continuation_token( + return LROPoller[_models.GalleryApplicationVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GalleryApplication]( + return LROPoller[_models.GalleryApplicationVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -3811,7 +4283,8 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], + gallery_application_version_name: str, + gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -3832,15 +4305,16 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(gallery_application, (IOBase, bytes)): - _content = gallery_application + if isinstance(gallery_application_version, (IOBase, bytes)): + _content = gallery_application_version else: - _json = self._serialize.body(gallery_application, "GalleryApplicationUpdate") + _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") - _request = build_gallery_applications_update_request( + _request = build_gallery_application_versions_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -3859,18 +4333,24 @@ 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): pass 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) + + 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 @@ -3880,32 +4360,36 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: _models.GalleryApplicationUpdate, + gallery_application_version_name: str, + gallery_application_version: _models.GalleryApplicationVersionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationUpdate + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the update gallery Application + Version operation. Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionUpdate :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 GalleryApplication or the result of - cls(response) + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3915,32 +4399,35 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: IO[bytes], + gallery_application_version_name: str, + gallery_application_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. - Required. - :type gallery_application: IO[bytes] + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the update gallery Application + Version operation. Required. + :type gallery_application_version: 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 GalleryApplication or the result of - cls(response) + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3950,28 +4437,32 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], + gallery_application_version_name: str, + gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GalleryApplication]: - """Update a gallery Application Definition. + ) -> LROPoller[_models.GalleryApplicationVersion]: + """Update a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be updated. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be updated. - The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the - middle. The maximum length is 80 characters. Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str - :param gallery_application: Parameters supplied to the update gallery Application operation. Is - either a GalleryApplicationUpdate type or a IO[bytes] type. Required. - :type gallery_application: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationUpdate or - IO[bytes] - :return: An instance of LROPoller that returns either GalleryApplication or the result of - cls(response) + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_name: str + :param gallery_application_version: Parameters supplied to the update gallery Application + Version operation. Is either a GalleryApplicationVersionUpdate type or a IO[bytes] type. + Required. + :type gallery_application_version: + ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionUpdate or IO[bytes] + :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3979,7 +4470,7 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryApplicationVersion] = 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) @@ -3988,7 +4479,8 @@ def begin_update( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, - gallery_application=gallery_application, + gallery_application_version_name=gallery_application_version_name, + gallery_application_version=gallery_application_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4000,91 +4492,37 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) + deserialized = self._deserialize("GalleryApplicationVersion", 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.GalleryApplication].from_continuation_token( + return LROPoller[_models.GalleryApplicationVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GalleryApplication]( + return LROPoller[_models.GalleryApplicationVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> _models.GalleryApplication: - """Retrieves information about a gallery Application Definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery from which the Application - Definitions are to be retrieved. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be - retrieved. Required. - :type gallery_application_name: str - :return: GalleryApplication or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplication - :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) - - _request = build_gallery_applications_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_application_name=gallery_application_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("GalleryApplication", 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, gallery_name: str, gallery_application_name: str, **kwargs: Any + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4100,10 +4538,11 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_gallery_applications_delete_request( + _request = build_gallery_application_versions_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4125,29 +4564,43 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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, gallery_name: str, gallery_application_name: str, **kwargs: Any + self, + resource_group_name: str, + gallery_name: str, + gallery_application_name: str, + gallery_application_version_name: str, + **kwargs: Any ) -> LROPoller[None]: - """Delete a gallery Application. + """Delete a gallery Application Version. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition is to be deleted. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition to be deleted. - Required. + :param gallery_application_name: The name of the gallery Application Definition to be + retrieved. Required. :type gallery_application_name: str + :param gallery_application_version_name: The name of the gallery Application Version to be + retrieved. Required. + :type gallery_application_version_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: @@ -4165,6 +4618,7 @@ def begin_delete( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, + gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4179,7 +4633,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: @@ -4193,26 +4649,47 @@ 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 GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s + :attr:`gallery_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_by_gallery( self, resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplication"]: - """List gallery Application Definitions in a gallery. + ) -> Iterable["_models.GalleryImage"]: + """List gallery image definitions in a gallery. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery from which Application - Definitions are to be listed. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :return: An iterator like instance of either GalleryApplication or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplication] + :return: An iterator like instance of either GalleryImage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImageList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4225,7 +4702,7 @@ def list_by_gallery( def prepare_request(next_link=None): if not next_link: - _request = build_gallery_applications_list_by_gallery_request( + _request = build_gallery_images_list_by_gallery_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, @@ -4253,7 +4730,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("GalleryApplicationList", pipeline_response) + deserialized = self._deserialize("GalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -4270,40 +4747,80 @@ 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) + @distributed_trace + def get( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> _models.GalleryImage: + """Retrieves information about a gallery image definition. -class GalleryApplicationVersionsOperations: - """ - .. 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :return: GalleryImage or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage + :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.v2023_07_03.ComputeManagementClient`'s - :attr:`gallery_application_versions` 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 "2023-07-03")) + cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) - 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") + _request = build_gallery_images_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryImage", 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, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4324,16 +4841,15 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version + if isinstance(gallery_image, (IOBase, bytes)): + _content = gallery_image else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") + _json = self._serialize.body(gallery_image, "GalleryImage") - _request = build_gallery_application_versions_create_or_update_request( + _request = build_gallery_images_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, + gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4358,12 +4874,21 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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 @@ -4372,39 +4897,30 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersion, + gallery_image_name: str, + gallery_image: _models.GalleryImage, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update a gallery Application Version. - - :param resource_group_name: The name of the resource group. Required. + ) -> LROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the create or update gallery - Application Version operation. Required. - :type gallery_application_version: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. + Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage :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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4413,38 +4929,30 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: IO[bytes], + gallery_image_name: str, + gallery_image: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update a gallery Application Version. + ) -> LROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the create or update gallery - Application Version operation. Required. - :type gallery_application_version: IO[bytes] + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. + Required. + :type gallery_image: 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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4453,35 +4961,25 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Create or update a gallery Application Version. + ) -> LROPoller[_models.GalleryImage]: + """Create or update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be created. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - created. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the create or update gallery - Application Version operation. Is either a GalleryApplicationVersion type or a IO[bytes] type. - Required. - :type gallery_application_version: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion or IO[bytes] - :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the create or update gallery image operation. Is + either a GalleryImage type or a IO[bytes] type. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImage or IO[bytes] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4489,7 +4987,7 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImage] = 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) @@ -4497,9 +4995,8 @@ def begin_create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, - gallery_application_version=gallery_application_version, + gallery_image_name=gallery_image_name, + gallery_image=gallery_image, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4511,25 +5008,27 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) + deserialized = self._deserialize("GalleryImage", 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.GalleryApplicationVersion].from_continuation_token( + return LROPoller[_models.GalleryImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GalleryApplicationVersion]( + return LROPoller[_models.GalleryImage]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) @@ -4537,9 +5036,8 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -4560,16 +5058,15 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(gallery_application_version, (IOBase, bytes)): - _content = gallery_application_version + if isinstance(gallery_image, (IOBase, bytes)): + _content = gallery_image else: - _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") + _json = self._serialize.body(gallery_image, "GalleryImageUpdate") - _request = build_gallery_application_versions_update_request( + _request = build_gallery_images_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, + gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -4588,18 +5085,24 @@ 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): pass 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) + + 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 @@ -4608,39 +5111,29 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: _models.GalleryApplicationVersionUpdate, + gallery_image_name: str, + gallery_image: _models.GalleryImageUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update a gallery Application Version. + ) -> LROPoller[_models.GalleryImage]: + """Update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the update gallery Application - Version operation. Required. - :type gallery_application_version: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionUpdate + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate :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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4649,38 +5142,29 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: IO[bytes], + gallery_image_name: str, + gallery_image: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update a gallery Application Version. + ) -> LROPoller[_models.GalleryImage]: + """Update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the update gallery Application - Version operation. Required. - :type gallery_application_version: IO[bytes] + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Required. + :type gallery_image: 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 GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -4689,35 +5173,25 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], + gallery_image_name: str, + gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.GalleryApplicationVersion]: - """Update a gallery Application Version. + ) -> LROPoller[_models.GalleryImage]: + """Update a gallery image definition. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version is to be updated. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - updated. Needs to follow semantic version name pattern: The allowed characters are digit and - period. Digits must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_application_version_name: str - :param gallery_application_version: Parameters supplied to the update gallery Application - Version operation. Is either a GalleryApplicationVersionUpdate type or a IO[bytes] type. - Required. - :type gallery_application_version: - ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image: Parameters supplied to the update gallery image operation. Is either a + GalleryImageUpdate type or a IO[bytes] type. Required. + :type gallery_image: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageUpdate or IO[bytes] + :return: An instance of LROPoller that returns either GalleryImage or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4725,7 +5199,7 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImage] = 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) @@ -4733,9 +5207,8 @@ def begin_update( raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, - gallery_application_version=gallery_application_version, + gallery_image_name=gallery_image_name, + gallery_image=gallery_image, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -4747,119 +5220,40 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) + deserialized = self._deserialize("GalleryImage", 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.GalleryApplicationVersion].from_continuation_token( + return LROPoller[_models.GalleryImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.GalleryApplicationVersion]( + return LROPoller[_models.GalleryImage]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - @distributed_trace - def get( - self, - resource_group_name: str, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - *, - expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, - **kwargs: Any - ) -> _models.GalleryApplicationVersion: - """Retrieves information about a gallery Application Version. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. - :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version resides. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - retrieved. Required. - :type gallery_application_version_name: str - :keyword expand: The expand expression to apply on the operation. Known values are: - "ReplicationStatus" and "UefiSettings". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes - :return: GalleryApplicationVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion - :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) - - _request = build_gallery_application_versions_get_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_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("GalleryApplicationVersion", 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_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 {}) + def _delete_initial( + self, resource_group_name: str, gallery_name: str, gallery_image_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 {}) @@ -4867,11 +5261,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_gallery_application_versions_delete_request( + _request = build_gallery_images_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, + gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -4893,37 +5286,34 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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, - gallery_name: str, - gallery_application_name: str, - gallery_application_version_name: str, - **kwargs: Any + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any ) -> LROPoller[None]: - """Delete a gallery Application Version. + """Delete a gallery 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 gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. + :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str - :param gallery_application_name: The name of the gallery Application Definition in which the - Application Version resides. Required. - :type gallery_application_name: str - :param gallery_application_version_name: The name of the gallery Application Version to be - deleted. Required. - :type gallery_application_version_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_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: @@ -4940,8 +5330,7 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, - gallery_application_name=gallery_application_name, - gallery_application_version_name=gallery_application_version_name, + gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -4956,7 +5345,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: @@ -4967,647 +5358,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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_gallery_application( - self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersion"]: - """List gallery Application Versions in a gallery Application Definition. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Application Gallery in which the Application - Definition resides. Required. - :type gallery_name: str - :param gallery_application_name: The name of the Shared Application Gallery Application - Definition from which the Application Versions are to be listed. Required. - :type gallery_application_name: str - :return: An iterator like instance of either GalleryApplicationVersion or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryApplicationVersion] - :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 "2023-07-03")) - cls: ClsType[_models.GalleryApplicationVersionList] = 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_gallery_application_versions_list_by_gallery_application_request( - resource_group_name=resource_group_name, - gallery_name=gallery_name, - gallery_application_name=gallery_application_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("GalleryApplicationVersionList", 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 GallerySharingProfileOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`gallery_sharing_profile` 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 _update_initial( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, IO[bytes]], - **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 "2023-07-03")) - 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(sharing_update, (IOBase, bytes)): - _content = sharing_update - else: - _json = self._serialize.body(sharing_update, "SharingUpdate") - - _request = build_gallery_sharing_profile_update_request( - resource_group_name=resource_group_name, - gallery_name=gallery_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) - - 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_update( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: _models.SharingUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. Required. - :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. - :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate - :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 SharingUpdate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. Required. - :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. - :type sharing_update: 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 SharingUpdate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - gallery_name: str, - sharing_update: Union[_models.SharingUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SharingUpdate]: - """Update sharing profile of a gallery. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param gallery_name: The name of the Shared Image Gallery. Required. - :type gallery_name: str - :param sharing_update: Parameters supplied to the update gallery sharing profile. Is either a - SharingUpdate type or a IO[bytes] type. Required. - :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate or IO[bytes] - :return: An instance of LROPoller that returns either SharingUpdate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] - :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 "2023-07-03")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharingUpdate] = 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, - gallery_name=gallery_name, - sharing_update=sharing_update, - 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("SharingUpdate", 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.SharingUpdate].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SharingUpdate]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - -class SharedGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`shared_galleries` 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, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGallery"]: - """List shared galleries by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGallery or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGallery] - :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryList] = 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_shared_galleries_list_request( - location=location, - subscription_id=self._config.subscription_id, - shared_to=shared_to, - 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("SharedGalleryList", 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, location: str, gallery_unique_name: str, **kwargs: Any) -> _models.SharedGallery: - """Get a shared gallery by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :return: SharedGallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGallery - :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 "2023-07-03")) - cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) - - _request = build_shared_galleries_get_request( - location=location, - gallery_unique_name=gallery_unique_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("SharedGallery", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class SharedGalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`shared_gallery_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( - self, - location: str, - gallery_unique_name: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, - **kwargs: Any - ) -> Iterable["_models.SharedGalleryImage"]: - """List shared gallery images by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage] - :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageList] = 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_shared_gallery_images_list_request( - location=location, - gallery_unique_name=gallery_unique_name, - subscription_id=self._config.subscription_id, - shared_to=shared_to, - 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("SharedGalleryImageList", 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, location: str, gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.SharedGalleryImage: - """Get a shared gallery image by subscription id or tenant id. - - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. - :type gallery_image_name: str - :return: SharedGalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImage - :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) - - _request = build_shared_gallery_images_get_request( - location=location, - gallery_unique_name=gallery_unique_name, - gallery_image_name=gallery_image_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("SharedGalleryImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore -class SharedGalleryImageVersionsOperations: +class GalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`shared_gallery_image_versions` attribute. + :attr:`gallery_image_versions` attribute. """ models = _models @@ -5621,38 +5383,28 @@ 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, - gallery_unique_name: str, - gallery_image_name: str, - *, - shared_to: Optional[Union[str, _models.SharedToValues]] = None, - **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageVersion"]: - """List shared gallery image versions by subscription id or tenant id. + def list_by_gallery_image( + self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any + ) -> Iterable["_models.GalleryImageVersion"]: + """List gallery image versions in a gallery image definition. - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. :type gallery_image_name: str - :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing - listing operations. "tenant" Default value is None. - :paramtype shared_to: str or ~azure.mgmt.compute.v2023_07_03.models.SharedToValues - :return: An iterator like instance of either SharedGalleryImageVersion or the result of - cls(response) + :return: An iterator like instance of either GalleryImageVersion or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageVersionList] = kwargs.pop("cls", None) + cls: ClsType[_models.GalleryImageVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5665,12 +5417,11 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_shared_gallery_image_versions_list_request( - location=location, - gallery_unique_name=gallery_unique_name, + _request = build_gallery_image_versions_list_by_gallery_image_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, - shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, @@ -5695,7 +5446,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("SharedGalleryImageVersionList", pipeline_response) + deserialized = self._deserialize("GalleryImageVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -5712,39 +5463,334 @@ 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) @distributed_trace - def get( + def get( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + *, + expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, + **kwargs: Any + ) -> _models.GalleryImageVersion: + """Retrieves information about a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :keyword expand: The expand expression to apply on the operation. Known values are: + "ReplicationStatus" and "UefiSettings". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2023_07_03.models.ReplicationStatusTypes + :return: GalleryImageVersion or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion + :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 "2023-07-03")) + cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) + + _request = build_gallery_image_versions_get_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GalleryImageVersion", 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, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], + **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 "2023-07-03")) + 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(gallery_image_version, (IOBase, bytes)): + _content = gallery_image_version + else: + _json = self._serialize.body(gallery_image_version, "GalleryImageVersion") + + _request = build_gallery_image_versions_create_or_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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, 201, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + 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_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: _models.GalleryImageVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion + :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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Required. + :type gallery_image_version: 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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( self, - location: str, - gallery_unique_name: str, + resource_group_name: str, + gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], **kwargs: Any - ) -> _models.SharedGalleryImageVersion: - """Get a shared gallery image version by subscription id or tenant id. + ) -> LROPoller[_models.GalleryImageVersion]: + """Create or update a gallery image version. - :param location: Resource location. Required. - :type location: str - :param gallery_unique_name: The unique name of the Shared Gallery. Required. - :type gallery_unique_name: str - :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image - Versions are to be listed. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. :type gallery_image_name: str - :param gallery_image_version_name: The name of the gallery image version to be created. Needs - to follow semantic version name pattern: The allowed characters are digit and period. Digits - must be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. :type gallery_image_version_name: str - :return: SharedGalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.SharedGalleryImageVersion + :param gallery_image_version: Parameters supplied to the create or update gallery image version + operation. Is either a GalleryImageVersion type or a IO[bytes] type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion or + IO[bytes] + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryImageVersion] = 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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, + gallery_image_version=gallery_image_version, + 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("GalleryImageVersion", 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.GalleryImageVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GalleryImageVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5753,154 +5799,230 @@ 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 "2023-07-03")) - cls: ClsType[_models.SharedGalleryImageVersion] = 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_shared_gallery_image_versions_get_request( - location=location, - gallery_unique_name=gallery_unique_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(gallery_image_version, (IOBase, bytes)): + _content = gallery_image_version + else: + _json = self._serialize.body(gallery_image_version, "GalleryImageVersionUpdate") + + _request = build_gallery_image_versions_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedGalleryImageVersion", 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 begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: _models.GalleryImageVersionUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. -class CommunityGalleriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`community_galleries` attribute. - """ + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate + :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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - models = _models + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. - 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Required. + :type gallery_image_version: 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 GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, location: str, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: - """Get a community gallery by gallery public name. + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.GalleryImageVersion]: + """Update a gallery image version. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :return: CommunityGallery or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGallery + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_name: str + :param gallery_image_version: Parameters supplied to the update gallery image version + operation. Is either a GalleryImageVersionUpdate type or a IO[bytes] type. Required. + :type gallery_image_version: ~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersionUpdate + or IO[bytes] + :return: An instance of LROPoller that returns either GalleryImageVersion or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.GalleryImageVersion] :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 "2023-07-03")) - cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GalleryImageVersion] = 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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, + gallery_image_version=gallery_image_version, + 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_community_galleries_get_request( - location=location, - public_gallery_name=public_gallery_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("GalleryImageVersion", 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.GalleryImageVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GalleryImageVersion]( + 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("CommunityGallery", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class CommunityGalleryImagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`community_gallery_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 get( - self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> _models.CommunityGalleryImage: - """Get a community gallery image. - - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :return: CommunityGalleryImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5913,12 +6035,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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_community_gallery_images_get_request( - location=location, - public_gallery_name=public_gallery_name, + _request = build_gallery_image_versions_delete_request( + resource_group_name=resource_group_name, + gallery_name=gallery_name, gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -5926,115 +6049,113 @@ def get( ) _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommunityGalleryImage", 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, location: str, public_gallery_name: str, **kwargs: Any) -> Iterable["_models.CommunityGalleryImage"]: - """List community gallery images inside a gallery. + def begin_delete( + self, + resource_group_name: str, + gallery_name: str, + gallery_image_name: str, + gallery_image_version_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a gallery image version. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :return: An iterator like instance of either CommunityGalleryImage or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImage] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. + :type gallery_image_name: str + :param gallery_image_version_name: The name of the gallery image version to be retrieved. + Required. + :type gallery_image_version_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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageList] = 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_community_gallery_images_list_request( - location=location, - public_gallery_name=public_gallery_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, + gallery_name=gallery_name, + gallery_image_name=gallery_image_name, + gallery_image_version_name=gallery_image_version_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("CommunityGalleryImageList", 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 -class CommunityGalleryImageVersionsOperations: +class GallerySharingProfileOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2023_07_03.ComputeManagementClient`'s - :attr:`community_gallery_image_versions` attribute. + :attr:`gallery_sharing_profile` attribute. """ models = _models @@ -6047,32 +6168,13 @@ 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 get( + def _update_initial( self, - location: str, - public_gallery_name: str, - gallery_image_name: str, - gallery_image_version_name: str, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO[bytes]], **kwargs: Any - ) -> _models.CommunityGalleryImageVersion: - """Get a community gallery image version. - - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :param gallery_image_version_name: The name of the community gallery image version. Needs to - follow semantic version name pattern: The allowed characters are digit and period. Digits must - be within the range of a 32-bit integer. Format: :code:``.\\ - :code:``.\\ :code:``. Required. - :type gallery_image_version_name: str - :return: CommunityGalleryImageVersion or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6081,125 +6183,187 @@ 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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageVersion] = 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_community_gallery_image_versions_get_request( - location=location, - public_gallery_name=public_gallery_name, - gallery_image_name=gallery_image_name, - gallery_image_version_name=gallery_image_version_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sharing_update, (IOBase, bytes)): + _content = sharing_update + else: + _json = self._serialize.body(sharing_update, "SharingUpdate") + + _request = build_gallery_sharing_profile_update_request( + resource_group_name=resource_group_name, + gallery_name=gallery_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CommunityGalleryImageVersion", 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, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.CommunityGalleryImageVersion"]: - """List community gallery image versions inside an image. + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: _models.SharingUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - :param location: Resource location. Required. - :type location: str - :param public_gallery_name: The public name of the community gallery. Required. - :type public_gallery_name: str - :param gallery_image_name: The name of the community gallery image definition. Required. - :type gallery_image_name: str - :return: An iterator like instance of either CommunityGalleryImageVersion 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. + :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate + :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 SharingUpdate or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2023_07_03.models.CommunityGalleryImageVersion] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] :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 "2023-07-03")) - cls: ClsType[_models.CommunityGalleryImageVersionList] = kwargs.pop("cls", None) + @overload + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. + :type sharing_update: 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 SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @distributed_trace + def begin_update( + self, + resource_group_name: str, + gallery_name: str, + sharing_update: Union[_models.SharingUpdate, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SharingUpdate]: + """Update sharing profile of a gallery. - _request = build_community_gallery_image_versions_list_request( - location=location, - public_gallery_name=public_gallery_name, - gallery_image_name=gallery_image_name, - subscription_id=self._config.subscription_id, - 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 gallery_name: The name of the Shared Image Gallery. Required. + :type gallery_name: str + :param sharing_update: Parameters supplied to the update gallery sharing profile. Is either a + SharingUpdate type or a IO[bytes] type. Required. + :type sharing_update: ~azure.mgmt.compute.v2023_07_03.models.SharingUpdate or IO[bytes] + :return: An instance of LROPoller that returns either SharingUpdate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2023_07_03.models.SharingUpdate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-03")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharingUpdate] = 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, + gallery_name=gallery_name, + sharing_update=sharing_update, + 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("CommunityGalleryImageVersionList", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharingUpdate", pipeline_response.http_response) 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, 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) ) - 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[_models.SharingUpdate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SharingUpdate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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..9a009f02c2be 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 @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -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: @@ -627,21 +840,89 @@ 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. + + :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, + 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _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, + 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("PrivateLinkResourceListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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 +935,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 +963,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 +986,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 +1013,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 +1074,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 +1109,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] + :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 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: """ @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 +1231,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 +1252,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 +1266,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 +1293,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 +1312,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 +1320,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 +1360,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, @@ -1086,14 +1395,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 DiskAccessesOperations: +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_accesses` attribute. + :attr:`disk_encryption_sets` attribute. """ models = _models @@ -1106,13 +1415,21 @@ 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, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + @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, @@ -1121,193 +1438,203 @@ async 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 {}) - - 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) + def prepare_request(next_link=None): + if not next_link: - 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") + _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) - _request = build_disk_accesses_create_or_update_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) + 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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + 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) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - 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) + _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, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) - @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. + @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 - :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. + :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.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] + :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 {}) - @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. + 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) - :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] - :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_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 begin_create_or_update( - 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. + 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. + :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 - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~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: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet :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-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, 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, - 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.DiskEncryptionSet] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _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) - 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.DiskAccess].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DiskAccess]( - 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("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_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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -1328,14 +1655,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, "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, @@ -1362,95 +1689,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_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 - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) 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. - :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 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 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: """ @overload - async def begin_update( + async 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 - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) 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. - :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 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: """ @distributed_trace_async - async def begin_update( + async 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 - ) -> AsyncLROPoller[_models.DiskAccess]: - """Updates (patches) 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 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 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 {}) @@ -1458,15 +1797,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( + 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, @@ -1478,86 +1817,36 @@ 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 + async def _update_initial( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1567,17 +1856,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-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_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, ) @@ -1591,7 +1892,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): @@ -1599,59 +1900,263 @@ 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 - ) -> AsyncLROPoller[None]: - """Deletes a disk access resource. + @overload + async 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 + ) -> 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[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 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: """ - _headers = kwargs.pop("headers", {}) or {} - _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, 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, - disk_access_name=disk_access_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: + @overload + async 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 + ) -> AsyncLROPoller[_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. 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_update( + self, + resource_group_name: str, + disk_encryption_set_name: str, + disk_encryption_set: Union[_models.DiskEncryptionSetUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_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 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: + """ + _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, 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_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 + ) + 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) + 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.DiskEncryptionSet].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 + ) + + async def _delete_initial( + self, resource_group_name: str, disk_encryption_set_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-03-02")) + cls: ClsType[AsyncIterator[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 = 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, disk_encryption_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[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 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-03-02")) + 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, + disk_encryption_set_name=disk_encryption_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( @@ -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,33 +2252,53 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @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 {}) +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - 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) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_03_02.aio.ComputeManagementClient`'s + :attr:`disks` attribute. + """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + 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.Disk"]: + """Lists all the disks under a subscription. + + :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_disk_accesses_list_request( + _request = build_disks_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -1792,7 +2324,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 @@ -1815,72 +2347,23 @@ 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. + @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. 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 + :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: """ - 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _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, - 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("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + cls: ClsType[_models.DiskList] = kwargs.pop("cls", None) - 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 - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1889,224 +2372,72 @@ async def _update_a_private_endpoint_connection_initial( # pylint: disable=name } 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(private_endpoint_connection, (IOBase, bytes)): - _content = private_endpoint_connection - else: - _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - - _request = build_disk_accesses_update_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, - 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_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: _models.PrivateEndpointConnection, - *, - 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. - - :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 - :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 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: - """ + def prepare_request(next_link=None): + if not next_link: - @overload - 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: 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. + _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) - :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 - :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: - """ + 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_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 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) - :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 - :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 {}) - _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-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._update_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, - private_endpoint_connection=private_endpoint_connection, - api_version=api_version, - content_type=content_type, - 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): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + 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[_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 - ) + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @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. + 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 - :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 + :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 = { @@ -2121,12 +2452,11 @@ async def get_a_private_endpoint_connection( _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) + cls: ClsType[_models.Disk] = kwargs.pop("cls", None) - _request = build_disk_accesses_get_a_private_endpoint_connection_request( + _request = build_disks_get_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, headers=_headers, @@ -2145,15 +2475,15 @@ async def get_a_private_endpoint_connection( 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) + deserialized = self._deserialize("Disk", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # 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 _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, @@ -2163,18 +2493,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, "Disk") + + _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, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -2188,7 +2529,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,45 +2537,112 @@ 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_create_or_update( + self, + resource_group_name: str, + disk_name: str, + disk: _models.Disk, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Creates or updates 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 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 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_create_or_update( + self, + resource_group_name: str, + disk_name: str, + disk: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Disk]: + """Creates or updates 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 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 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_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 - :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 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 = 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._create_or_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, @@ -2243,138 +2651,33 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=name-to 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("Disk", 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.Disk].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. - """ - - 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.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 + 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, @@ -2394,14 +2697,14 @@ async def _create_or_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(disk, (IOBase, bytes)): + _content = disk else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + _json = self._serialize.body(disk, "DiskUpdate") - _request = build_disk_encryption_sets_create_or_update_request( + _request = build_disks_update_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, @@ -2428,99 +2731,94 @@ 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_update( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, + disk_name: str, + disk: _models.DiskUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> 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_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 + :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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :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_create_or_update( + async def begin_update( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: IO[bytes], + disk_name: str, + disk: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DiskEncryptionSet]: - """Creates or updates a disk encryption set. + ) -> 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_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] + :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 DiskEncryptionSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet] + :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_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_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_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 + :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2528,15 +2826,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.DiskEncryptionSet] = 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._create_or_update_initial( + raw_result = await self._update_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, + disk=disk, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2548,33 +2846,145 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskEncryptionSet", 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)) + 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.Disk].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.Disk]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _update_initial( + 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 {}) + + _headers = kwargs.pop("headers", {}) or {} + _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) + + 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, disk_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes 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: 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-03-02")) + 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, + disk_name=disk_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 _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. - - :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. Required. - :type disk_encryption_set: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSetUpdate + ) -> AsyncLROPoller[_models.AccessUri]: + """Grants access to 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 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,163 +3230,112 @@ 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _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, 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, - disk_encryption_set_name=disk_encryption_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 - 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) + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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 + 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, 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( + resource_group_name=resource_group_name, + disk_name=disk_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("DiskEncryptionSetList", 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 + 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) - return pipeline_response +class SnapshotsOperations: + """ + .. 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_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") @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,134 +3503,38 @@ 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, 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("DiskRestorePoint", 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 + ) + _request.url = self._client.format_url(_request.url) - 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) + _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("Snapshot", 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, - 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,263 +3588,115 @@ 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. - - :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 - :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] - :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: - """ - - @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. + ) -> 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 - cls(response) - :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 {}) - _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.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._grant_access_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, - 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("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, 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.AccessUri].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AccessUri]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async 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 - ) -> 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-03-02")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disk_restore_point_revoke_access_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) - - _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 + :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: + """ @distributed_trace_async - async 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 - ) -> AsyncLROPoller[None]: - """Revokes access to a diskRestorePoint. + 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 - :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 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] :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._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, + 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 +3705,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 +3720,22 @@ 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 _update_initial( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3747,9 +3758,9 @@ async def _create_or_update_initial( if isinstance(snapshot, (IOBase, bytes)): _content = snapshot else: - _json = self._serialize.body(snapshot, "Snapshot") + _json = self._serialize.body(snapshot, "SnapshotUpdate") - _request = build_snapshots_create_or_update_request( + _request = build_snapshots_update_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -3778,33 +3789,40 @@ 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_update( self, resource_group_name: str, snapshot_name: str, - snapshot: _models.Snapshot, + snapshot: _models.SnapshotUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a 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 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 + :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 @@ -3815,7 +3833,7 @@ async def begin_create_or_update( """ @overload - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, snapshot_name: str, @@ -3824,15 +3842,17 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a 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 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. + :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". @@ -3844,20 +3864,25 @@ async def begin_create_or_update( """ @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 + async def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.Snapshot]: - """Creates or updates a 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 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] + :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] @@ -3867,18 +3892,134 @@ async def begin_create_or_update( _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) + 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._update_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, + **kwargs + ) + 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) + 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.Snapshot].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 + ) + + async def _delete_initial( + self, resource_group_name: str, snapshot_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-03-02")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _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, + 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, snapshot_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes 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 + :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-03-02")) + 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,23 +4370,46 @@ 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.Snapshot"]: - """Lists snapshots under a resource group. - :param resource_group_name: The name of the resource group. Required. +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 list_by_restore_point( + self, resource_group_name: str, restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any + ) -> List[_models.DiskRestorePoint]: + """Lists diskRestorePoints under a vmRestorePoint. + + :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.async_paging.AsyncItemPaged[~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: list of DiskRestorePoint or the result of cls(response) + :rtype: list[~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, @@ -4292,74 +4418,67 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[List[_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_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) - 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 - @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 +4487,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 +4555,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 +4586,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 +4602,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 +4639,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 +4676,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 +4715,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 +4755,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 +4776,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 +4804,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 +4853,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..b78a04477ba0 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,8 @@ DiskEncryptionSetList, DiskEncryptionSetUpdate, DiskList, + DiskPurchasePlan, DiskRestorePoint, - DiskRestorePointList, DiskSecurityProfile, DiskSku, DiskUpdate, @@ -50,9 +50,9 @@ PrivateLinkResourceListResult, PrivateLinkServiceConnectionState, PropertyUpdatesInProgress, - ProxyOnlyResource, - PurchasePlan, + ProxyResource, Resource, + ResourceAutoGenerated, ResourceUriList, ResourceWithOptionalLocation, ShareInfoElement, @@ -65,13 +65,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 +113,8 @@ "DiskEncryptionSetList", "DiskEncryptionSetUpdate", "DiskList", + "DiskPurchasePlan", "DiskRestorePoint", - "DiskRestorePointList", "DiskSecurityProfile", "DiskSku", "DiskUpdate", @@ -132,9 +136,9 @@ "PrivateLinkResourceListResult", "PrivateLinkServiceConnectionState", "PropertyUpdatesInProgress", - "ProxyOnlyResource", - "PurchasePlan", + "ProxyResource", "Resource", + "ResourceAutoGenerated", "ResourceUriList", "ResourceWithOptionalLocation", "ShareInfoElement", @@ -147,10 +151,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..e6e25d7d1f2e 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. -class DiskRestorePoint(ProxyOnlyResource): + 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 + """ + + +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,42 +1442,6 @@ def __init__( self.logical_sector_size = None -class DiskRestorePointList(_serialization.Model): - """The List Disk Restore Points operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: A list of disk restore points. 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. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DiskRestorePoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of disk restore points. 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. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - class DiskSecurityProfile(_serialization.Model): """Contains the security related information for the resource. @@ -1500,7 +1570,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 +1617,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 +1647,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 +1707,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 +1986,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 +2021,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 +2250,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 +2282,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 +2291,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 +2313,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 +2321,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 +2490,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 +2644,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 +2684,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 +2749,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 +2764,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 +2807,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 +2825,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 +2843,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 +2891,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 +2927,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 +2944,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 +3233,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 +3352,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..27fbd729b360 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 @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -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_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 {}) _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}/getPrivateLinkResources", ) # 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,31 @@ 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_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")) + 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", ) # 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 @@ -278,28 +298,39 @@ 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_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")) - 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 @@ -308,15 +339,17 @@ def build_disk_accesses_create_or_update_request( # pylint: disable=name-too-lo _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_accesses_update_request( - 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 {}) @@ -328,12 +361,17 @@ def build_disk_accesses_update_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}/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 @@ -346,11 +384,15 @@ def build_disk_accesses_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_disk_accesses_get_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 {}) @@ -361,12 +403,17 @@ 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}/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 @@ -377,12 +424,10 @@ def build_disk_accesses_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="DELETE", 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}/grantAccess", ) # 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}/revokeAccess", ) # 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 +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,88 @@ 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 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. + :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: 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, + 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.DiskList] = kwargs.pop("cls", None) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _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, + 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("PrivateLinkResourceListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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. + + :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] + :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, @@ -1830,8 +2191,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 +2219,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 +2243,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 +2269,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 +2330,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 +2365,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 +2487,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 +2508,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 +2522,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 +2549,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 +2568,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 +2576,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 +2616,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, @@ -2255,14 +2651,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 -class DiskAccessesOperations: +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_accesses` attribute. + :attr:`disk_encryption_sets` attribute. """ models = _models @@ -2275,13 +2671,20 @@ 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, - disk_access_name: str, - disk_access: Union[_models.DiskAccess, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_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.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, @@ -2290,190 +2693,198 @@ 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-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_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) - 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") + 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_create_or_update_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) + 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) - _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) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + return pipeline_response - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) - @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. + @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 - :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. + :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.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] + :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 {}) - @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. + 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) - :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: - """ + 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 + + 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_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 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. + :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 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 + :return: DiskEncryptionSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_03_02.models.DiskEncryptionSet :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-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + cls: ClsType[_models.DiskEncryptionSet] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiskAccess", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _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) - 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, - ) - return LROPoller[_models.DiskAccess]( - 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( + 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,46 +3894,33 @@ 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: - """ + 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, 404: ResourceNotFoundError, @@ -3274,44 +3929,190 @@ def get_a_private_endpoint_connection( } 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")) - cls: ClsType[_models.PrivateEndpointConnection] = 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_disk_accesses_get_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, ) _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("PrivateEndpointConnection", 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_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]: + @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. 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 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( + 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. + + :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 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. 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] + :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.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) + + 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 + + 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 _delete_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3326,10 +4127,9 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-l 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_accesses_delete_a_private_endpoint_connection_request( + _request = build_disks_delete_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, headers=_headers, @@ -3353,27 +4153,29 @@ 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. + 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_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 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: @@ -3387,10 +4189,9 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long 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( + raw_result = self._delete_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, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -3405,7 +4206,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: @@ -3419,30 +4222,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 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. - :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] - :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) - + def _grant_access_initial( + self, + resource_group_name: str, + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3451,114 +4237,24 @@ def list_private_endpoint_connections( } 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_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. - """ - - 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_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], - **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-03-02")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + 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 + if isinstance(grant_access_data, (IOBase, bytes)): + _content = grant_access_data else: - _json = self._serialize.body(disk_encryption_set, "DiskEncryptionSet") + _json = self._serialize.body(grant_access_data, "GrantAccessData") - _request = build_disk_encryption_sets_create_or_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, @@ -3585,96 +4281,100 @@ 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_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: _models.DiskEncryptionSet, + disk_name: str, + grant_access_data: _models.GrantAccessData, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates 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 Put disk - encryption set operation. Required. - :type disk_encryption_set: ~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 + :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_create_or_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]: - """Creates or updates 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 Put 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_create_or_update( + def begin_grant_access( self, resource_group_name: str, - disk_encryption_set_name: str, - disk_encryption_set: Union[_models.DiskEncryptionSet, IO[bytes]], + disk_name: str, + grant_access_data: Union[_models.GrantAccessData, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DiskEncryptionSet]: - """Creates or updates 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 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 + :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 {}) @@ -3682,15 +4382,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.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._create_or_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, @@ -3702,35 +4402,31 @@ def begin_create_or_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 ) - 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]: + def _revoke_access_initial(self, resource_group_name: str, disk_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3739,29 +4435,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-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, "DiskEncryptionSetUpdate") - - _request = build_disk_encryption_sets_update_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, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3783,262 +4467,29 @@ 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, - 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. + @distributed_trace + 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_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: - """ - - @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. - - :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. 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. 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, **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 - ) - - @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]: - 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) - - 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_encryption_set_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes 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_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. + :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.paging.ItemPaged[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,133 +4736,38 @@ 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, - 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("DiskRestorePoint", 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 + 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) - 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) + _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("Snapshot", 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, - 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,260 +4821,112 @@ 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. - - :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 - :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] - :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. - - :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 - :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] - :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.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._grant_access_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, - 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("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, 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.AccessUri].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AccessUri]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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, - 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_restore_point_revoke_access_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) - - _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 + ) -> LROPoller[_models.Snapshot]: + """Creates or updates a snapshot. - 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 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: + """ @distributed_trace - 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. + 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 - :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 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 = 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._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, + 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 +4935,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,37 +4950,22 @@ 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 + def _update_initial( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4886,9 +4988,9 @@ def _create_or_update_initial( if isinstance(snapshot, (IOBase, bytes)): _content = snapshot else: - _json = self._serialize.body(snapshot, "Snapshot") + _json = self._serialize.body(snapshot, "SnapshotUpdate") - _request = build_snapshots_create_or_update_request( + _request = build_snapshots_update_request( resource_group_name=resource_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, @@ -4917,33 +5019,40 @@ 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_update( self, resource_group_name: str, snapshot_name: str, - snapshot: _models.Snapshot, + snapshot: _models.SnapshotUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Snapshot]: - """Creates or updates a 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 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 + :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 @@ -4953,7 +5062,7 @@ def begin_create_or_update( """ @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, snapshot_name: str, @@ -4962,15 +5071,17 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Snapshot]: - """Creates or updates a 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 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. + :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". @@ -4981,40 +5092,159 @@ def begin_create_or_update( """ @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, snapshot_name: str, snapshot: Union[_models.Snapshot, IO[bytes]], **kwargs: Any + def begin_update( + self, + resource_group_name: str, + snapshot_name: str, + snapshot: Union[_models.SnapshotUpdate, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.Snapshot]: - """Creates or updates a 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 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] + :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 = case_insensitive_dict(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[_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._update_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, + **kwargs + ) + 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) + 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.Snapshot].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 + ) + + def _delete_initial(self, resource_group_name: str, snapshot_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_snapshots_delete_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) + + _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, snapshot_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes 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 + :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")) - 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,22 +5588,46 @@ 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 + ) -> List[_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: list of DiskRestorePoint or the result of cls(response) + :rtype: list[~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, @@ -5422,73 +5636,67 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-03-02")) + cls: ClsType[List[_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_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) - 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 @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 +5705,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 +5773,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 +5804,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 +5820,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 +5856,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 +5892,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 +5930,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 +5969,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 +5991,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 +6019,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 +6068,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_07_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_compute_management_client.py index 67e167d84a23..6a6cae65a228 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_07_01.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: + azure.mgmt.compute.v2024_07_01.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.v2024_07_01.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: + azure.mgmt.compute.v2024_07_01.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.v2024_07_01.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.v2024_07_01.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineRunCommandsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.compute.v2024_07_01.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineSizesOperations :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations :vartype virtual_machine_scale_sets: azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineExtensionsOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.compute.v2024_07_01.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineExtensionImagesOperations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_07_01.operations.AvailabilitySetsOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineSizesOperations :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations :vartype proximity_placement_groups: azure.mgmt.compute.v2024_07_01.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_07_01.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: azure.mgmt.compute.v2024_07_01.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_07_01.operations.SshPublicKeysOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_07_01.operations.ImagesOperations :ivar restore_point_collections: RestorePointCollectionsOperations operations :vartype restore_point_collections: azure.mgmt.compute.v2024_07_01.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_07_01.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_07_01.operations.CapacityReservationGroupsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.v2024_07_01.operations.SshPublicKeysOperations :ivar capacity_reservations: CapacityReservationsOperations operations :vartype capacity_reservations: azure.mgmt.compute.v2024_07_01.operations.CapacityReservationsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_07_01.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_07_01.operations.VirtualMachineRunCommandsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: azure.mgmt.compute.v2024_07_01.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.v2024_07_01.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.v2024_07_01.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.v2024_07_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_07_01.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.v2024_07_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-07-01") - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-07-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self.availability_sets = AvailabilitySetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self.capacity_reservation_groups = CapacityReservationGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self.dedicated_host_groups = DedicatedHostGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self.virtual_machine_images = VirtualMachineImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self.log_analytics = LogAnalyticsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machines = VirtualMachinesOperations( + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_images = VirtualMachineImagesOperations( + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self.virtual_machines = VirtualMachinesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.availability_sets = AvailabilitySetsOperations( + self.virtual_machine_sizes = VirtualMachineSizesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.proximity_placement_groups = ProximityPlacementGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( + self.restore_point_collections = RestorePointCollectionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.dedicated_hosts = DedicatedHostsOperations( + self.ssh_public_keys = SshPublicKeysOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.ssh_public_keys = SshPublicKeysOperations( + self.capacity_reservations = CapacityReservationsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") - self.restore_point_collections = RestorePointCollectionsOperations( + self.dedicated_hosts = DedicatedHostsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.restore_points = RestorePointsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.capacity_reservations = CapacityReservationsOperations( + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.log_analytics = LogAnalyticsOperations( + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-07-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_07_01/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_configuration.py index 22f72f6c2113..33f349332256 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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-07-01". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_metadata.json index f53d9ff2bf79..2c0dc49d43f7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_metadata.json +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_version.py index cad0623e3cd5..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "34.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_compute_management_client.py index adc02c6df27a..3858ce05febb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_07_01.aio.operations.Operations + :ivar availability_sets: AvailabilitySetsOperations operations + :vartype availability_sets: + azure.mgmt.compute.v2024_07_01.aio.operations.AvailabilitySetsOperations + :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations + :vartype capacity_reservation_groups: + azure.mgmt.compute.v2024_07_01.aio.operations.CapacityReservationGroupsOperations + :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations + :vartype dedicated_host_groups: + azure.mgmt.compute.v2024_07_01.aio.operations.DedicatedHostGroupsOperations + :ivar images: ImagesOperations operations + :vartype images: azure.mgmt.compute.v2024_07_01.aio.operations.ImagesOperations + :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations + :vartype virtual_machine_images_edge_zone: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineImagesEdgeZoneOperations + :ivar virtual_machine_images: VirtualMachineImagesOperations operations + :vartype virtual_machine_images: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineImagesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.compute.v2024_07_01.aio.operations.LogAnalyticsOperations + :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations + :vartype virtual_machine_extension_images: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineExtensionImagesOperations + :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations + :vartype virtual_machine_run_commands: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineRunCommandsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.compute.v2024_07_01.aio.operations.UsageOperations - :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations - :vartype virtual_machine_sizes: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineSizesOperations :ivar virtual_machine_scale_sets: VirtualMachineScaleSetsOperations operations :vartype virtual_machine_scale_sets: azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetsOperations - :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations - operations - :vartype virtual_machine_scale_set_extensions: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetExtensionsOperations - :ivar virtual_machine_scale_set_rolling_upgrades: - VirtualMachineScaleSetRollingUpgradesOperations operations - :vartype virtual_machine_scale_set_rolling_upgrades: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations - :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations - operations - :vartype virtual_machine_scale_set_vm_extensions: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetVMExtensionsOperations - :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations - :vartype virtual_machine_scale_set_vms: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetVMsOperations - :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations - :vartype virtual_machine_extensions: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineExtensionsOperations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachinesOperations - :ivar virtual_machine_images: VirtualMachineImagesOperations operations - :vartype virtual_machine_images: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineImagesOperations - :ivar virtual_machine_images_edge_zone: VirtualMachineImagesEdgeZoneOperations operations - :vartype virtual_machine_images_edge_zone: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineImagesEdgeZoneOperations - :ivar virtual_machine_extension_images: VirtualMachineExtensionImagesOperations operations - :vartype virtual_machine_extension_images: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineExtensionImagesOperations - :ivar availability_sets: AvailabilitySetsOperations operations - :vartype availability_sets: - azure.mgmt.compute.v2024_07_01.aio.operations.AvailabilitySetsOperations + :ivar virtual_machine_sizes: VirtualMachineSizesOperations operations + :vartype virtual_machine_sizes: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineSizesOperations :ivar proximity_placement_groups: ProximityPlacementGroupsOperations operations :vartype proximity_placement_groups: azure.mgmt.compute.v2024_07_01.aio.operations.ProximityPlacementGroupsOperations - :ivar dedicated_host_groups: DedicatedHostGroupsOperations operations - :vartype dedicated_host_groups: - azure.mgmt.compute.v2024_07_01.aio.operations.DedicatedHostGroupsOperations - :ivar dedicated_hosts: DedicatedHostsOperations operations - :vartype dedicated_hosts: - azure.mgmt.compute.v2024_07_01.aio.operations.DedicatedHostsOperations - :ivar ssh_public_keys: SshPublicKeysOperations operations - :vartype ssh_public_keys: azure.mgmt.compute.v2024_07_01.aio.operations.SshPublicKeysOperations - :ivar images: ImagesOperations operations - :vartype images: azure.mgmt.compute.v2024_07_01.aio.operations.ImagesOperations :ivar restore_point_collections: RestorePointCollectionsOperations operations :vartype restore_point_collections: azure.mgmt.compute.v2024_07_01.aio.operations.RestorePointCollectionsOperations - :ivar restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.compute.v2024_07_01.aio.operations.RestorePointsOperations - :ivar capacity_reservation_groups: CapacityReservationGroupsOperations operations - :vartype capacity_reservation_groups: - azure.mgmt.compute.v2024_07_01.aio.operations.CapacityReservationGroupsOperations + :ivar ssh_public_keys: SshPublicKeysOperations operations + :vartype ssh_public_keys: azure.mgmt.compute.v2024_07_01.aio.operations.SshPublicKeysOperations :ivar capacity_reservations: CapacityReservationsOperations operations :vartype capacity_reservations: azure.mgmt.compute.v2024_07_01.aio.operations.CapacityReservationsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.compute.v2024_07_01.aio.operations.LogAnalyticsOperations - :ivar virtual_machine_run_commands: VirtualMachineRunCommandsOperations operations - :vartype virtual_machine_run_commands: - azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineRunCommandsOperations + :ivar dedicated_hosts: DedicatedHostsOperations operations + :vartype dedicated_hosts: + azure.mgmt.compute.v2024_07_01.aio.operations.DedicatedHostsOperations + :ivar restore_points: RestorePointsOperations operations + :vartype restore_points: azure.mgmt.compute.v2024_07_01.aio.operations.RestorePointsOperations + :ivar virtual_machine_scale_set_rolling_upgrades: + VirtualMachineScaleSetRollingUpgradesOperations operations + :vartype virtual_machine_scale_set_rolling_upgrades: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetRollingUpgradesOperations + :ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensionsOperations + operations + :vartype virtual_machine_scale_set_extensions: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetExtensionsOperations + :ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMsOperations operations + :vartype virtual_machine_scale_set_vms: + azure.mgmt.compute.v2024_07_01.aio.operations.VirtualMachineScaleSetVMsOperations + :ivar virtual_machine_scale_set_vm_extensions: VirtualMachineScaleSetVMExtensionsOperations + operations + :vartype virtual_machine_scale_set_vm_extensions: + azure.mgmt.compute.v2024_07_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_07_01.aio.operations.VirtualMachineScaleSetVMRunCommandsOperations + :ivar virtual_machine_extensions: VirtualMachineExtensionsOperations operations + :vartype virtual_machine_extensions: + azure.mgmt.compute.v2024_07_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-07-01") - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") - self.virtual_machine_sizes = VirtualMachineSizesOperations( - self._client, self._config, self._serialize, self._deserialize, "2024-07-01" - ) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self.availability_sets = AvailabilitySetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self.capacity_reservation_groups = CapacityReservationGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self.dedicated_host_groups = DedicatedHostGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self.virtual_machine_images = VirtualMachineImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self.log_analytics = LogAnalyticsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machines = VirtualMachinesOperations( + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_images = VirtualMachineImagesOperations( + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self.virtual_machines = VirtualMachinesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.availability_sets = AvailabilitySetsOperations( + self.virtual_machine_sizes = VirtualMachineSizesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.proximity_placement_groups = ProximityPlacementGroupsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.dedicated_host_groups = DedicatedHostGroupsOperations( + self.restore_point_collections = RestorePointCollectionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.dedicated_hosts = DedicatedHostsOperations( + self.ssh_public_keys = SshPublicKeysOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.ssh_public_keys = SshPublicKeysOperations( + self.capacity_reservations = CapacityReservationsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize, "2024-07-01") - self.restore_point_collections = RestorePointCollectionsOperations( + self.dedicated_hosts = DedicatedHostsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.restore_points = RestorePointsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.capacity_reservations = CapacityReservationsOperations( + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.log_analytics = LogAnalyticsOperations( + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( self._client, self._config, self._serialize, self._deserialize, "2024-07-01" ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2024-07-01" + ) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_configuration.py index c8d72d0b6036..2fdd4787c0a9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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-07-01". Note that overriding this default value may result in unsupported behavior. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/__init__.py index 5cc9a11e2341..6718c8ecb4f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/_operations.py index 5a01c8b7fead..7a91236407f4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/aio/operations/_operations.py @@ -243,20 +243,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_07_01.models.ComputeOperationValue] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -294,11 +293,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) @@ -311,21 +310,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_07_01.aio.ComputeManagementClient`'s - :attr:`usage` attribute. + :attr:`availability_sets` attribute. """ models = _models @@ -339,21 +339,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_07_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_07_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-07-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -366,9 +369,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, @@ -393,7 +396,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 @@ -416,44 +419,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_07_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_07_01.models.VirtualMachineSize] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -466,8 +448,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, @@ -493,11 +475,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) @@ -516,117 +498,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_07_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_07_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_07_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-07-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, @@ -635,53 +519,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-07-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 @@ -689,174 +554,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_07_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_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -870,7 +642,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -878,14 +650,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, @@ -895,8 +665,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 ) @@ -904,14 +673,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 @@ -919,210 +684,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_07_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_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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-07-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 @@ -1130,84 +814,16 @@ 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. - - :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 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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 - - 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, - 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 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 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_07_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 = { @@ -1222,13 +838,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-07-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_delete_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, @@ -1242,26 +857,36 @@ async def get( 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) - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore + @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. + + :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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - 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, 404: ResourceNotFoundError, @@ -1270,213 +895,119 @@ async def _deallocate_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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _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) - 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 + # 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_sets_deallocate_request( - resource_group_name=resource_group_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, - ) - _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 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) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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 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]: - """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. +class CapacityReservationGroupsOperations: + """ + .. 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_07_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: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ - @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. + 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 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: - """ + 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_deallocate( + @distributed_trace + def list_by_subscription( 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, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = 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. + ) -> 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. - :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_07_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] + :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_07_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_07_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_07_01.models.CapacityReservationGroup] :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-07-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) - - 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.CapacityReservationGroupListResult] = kwargs.pop("cls", None) - async 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 - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1485,265 +1016,91 @@ async def _delete_instances_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-07-01")) - 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_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) - 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") + 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_sets_delete_instances_request( - resource_group_name=resource_group_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, - ) - _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) + 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) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + async def get_next(next_link=None): + _request = prepare_request(next_link) - if cls: - return cls(pipeline_response, 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 - return deserialized # 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 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 - ) -> AsyncLROPoller[None]: - """Deletes virtual machines in a VM scale set. + return pipeline_response - :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: - ~azure.mgmt.compute.v2024_07_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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return AsyncItemPaged(get_next, extract_data) - @overload - async def begin_delete_instances( + @distributed_trace + def list_by_resource_group( 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", + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> 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. - :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: 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 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_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 - ) -> AsyncLROPoller[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_07_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-07-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_07_01.models.VirtualMachineScaleSetInstanceView - :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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) - - _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) - - _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("VirtualMachineScaleSetInstanceView", 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.VirtualMachineScaleSet"]: - """Gets a list of all VM scale 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 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_07_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_07_01.models.VirtualMachineScaleSet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -1756,9 +1113,10 @@ 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_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, @@ -1783,7 +1141,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) + deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1806,24 +1164,33 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @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. + @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. - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] + :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 + :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_07_01.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1832,81 +1199,123 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineScaleS } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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("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) + _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 - @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. + @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. + :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetSku] + :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_07_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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + @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_07_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_07_01.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1915,82 +1324,278 @@ def list_skus( } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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 + 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") - 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) + _request = build_capacity_reservation_groups_create_or_update_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, + 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) + _stream = False + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # 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. + 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. - :param resource_group_name: The name of the resource 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) + :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_07_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_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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 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_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], + **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. 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 Update capacity reservation Group operation. Is + either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroupUpdate or + IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup + :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-07-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") + + _request = build_capacity_reservation_groups_update_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, + 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("CapacityReservationGroup", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # 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. + + :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 + :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-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_capacity_reservation_groups_delete_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) + + _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 + + +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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") + + @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. + + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.UpgradeOperationHistoricalStatusInfo] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -2003,9 +1608,7 @@ def get_os_upgrade_history( 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, + _request = build_dedicated_host_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -2031,7 +1634,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -2054,15 +1657,27 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - async def _power_off_initial( - 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, - **kwargs: Any - ) -> AsyncIterator[bytes]: + @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. 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_07_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-07-01")) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2071,55 +1686,121 @@ async def _power_off_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-07-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_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) - 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 + # 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_sets_power_off_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 + ) + 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, + host_group_name: str, + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, + **kwargs: Any + ) -> _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" and "userData". + Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + + _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, - skip_shutdown=skip_shutdown, + 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 @@ -2127,187 +1808,113 @@ async def _power_off_initial( return deserialized # type: ignore @overload - async def begin_power_off( + 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, *, - 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.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_07_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 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_07_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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_power_off( + 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], *, - 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.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] - :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 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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_power_off( + 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, - *, - skip_shutdown: bool = False, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, 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.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_07_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 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_07_01.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, - 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-07-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: - 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_restart_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, @@ -2318,23 +1925,18 @@ 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, 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 @@ -2342,132 +1944,81 @@ async def _restart_initial( return deserialized # type: ignore @overload - async def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_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_07_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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_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_07_01.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -2481,22 +2032,19 @@ async def _start_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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: - 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, "DedicatedHostGroupUpdate") - _request = build_virtual_machine_scale_sets_start_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, @@ -2507,152 +2055,37 @@ async def _start_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_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. + @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. + :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_07_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] + :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 - 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. 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_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. - - :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_07_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-07-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 - - 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, @@ -2665,11 +2098,11 @@ async def _reapply_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-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_reapply_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, headers=_headers, @@ -2677,97 +2110,56 @@ async def _reapply_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, 204]: 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")) + 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_07_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. + """ - @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. + 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[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") + + @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. + + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-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) - - 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 + cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - async def _redeploy_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, @@ -2776,190 +2168,154 @@ async def _redeploy_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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _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) - 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 + # 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_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) + 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) - _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 - - 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) + _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, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) - @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. + @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. 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_07_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] + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @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. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[_models.ImageListResult] = 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 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: - """ + 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_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. + 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 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_07_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 {}) + _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) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) + 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("ImageListResult", 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 - 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]: + 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, 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_07_01.models.Image + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2968,144 +2324,178 @@ async def _perform_maintenance_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-07-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.Image] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_perform_maintenance_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, + 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("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_perform_maintenance( - self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, - *, + 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-07-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 begin_create_or_update( + self, + resource_group_name: str, + image_name: str, + parameters: _models.Image, + *, 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. + ) -> AsyncLROPoller[_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_07_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_07_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 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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_perform_maintenance( + async 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 - ) -> 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. + ) -> AsyncLROPoller[_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 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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_perform_maintenance( - 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]: - """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. + 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. + :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_07_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 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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3113,15 +2503,15 @@ async def begin_perform_maintenance( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._perform_maintenance_initial( + raw_result = await 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, @@ -3132,30 +2522,36 @@ 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("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: 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.Image].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.Image]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _update_instances_initial( + async def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -3176,14 +2572,14 @@ async def _update_instances_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: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "ImageUpdate") - _request = build_virtual_machine_scale_sets_update_instances_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, @@ -3202,7 +2598,7 @@ async def _update_instances_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): @@ -3210,88 +2606,92 @@ async def _update_instances_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_update_instances( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + image_name: str, + parameters: _models.ImageUpdate, *, 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. + ) -> 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 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_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_instances( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], + image_name: str, + parameters: 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. + ) -> 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 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: IO[bytes] + :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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_instances( + async def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, 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. + ) -> AsyncLROPoller[_models.Image]: + """Update an 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 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_07_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] + :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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3299,15 +2699,15 @@ async def begin_update_instances( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._update_instances_initial( + raw_result = await 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, @@ -3318,32 +2718,32 @@ async def begin_update_instances( 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("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: 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.Image].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.Image]( + 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]: + async def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3352,32 +2752,17 @@ 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-07-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( + _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, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -3391,7 +2776,7 @@ async 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: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -3399,110 +2784,44 @@ 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( - 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_07_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. + 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. 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_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_07_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :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 = 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-07-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( + raw_result = await self._delete_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, + image_name=image_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -3516,7 +2835,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: @@ -3530,13 +2851,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 - 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]: + +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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") + + @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_07_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3545,190 +2894,121 @@ async def _reimage_all_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-07-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[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_reimage_all_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, ) _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_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. + @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. 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_07_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] + :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_07_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_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. + _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. 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: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - @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. + _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) - :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_07_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 {}) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) - 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]: + if cls: + return cls(pipeline_response, deserialized, {}) # 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. + + :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_07_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3737,215 +3017,80 @@ async def _approve_rolling_upgrade_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-07-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[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", 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, + _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, - 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) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def begin_approve_rolling_upgrade( + @distributed_trace_async + async def list( self, - resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, *, - content_type: str = "application/json", + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **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. 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_07_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: - """ + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, edge zone, + publisher, offer, and SKU. - @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. 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_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. - - :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_07_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-07-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 - ) - 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 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. 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_07_01.models.RecoveryWalkResponse + :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_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3960,15 +3105,18 @@ 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-07-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = 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, + _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, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -3984,92 +3132,36 @@ async def force_recovery_service_fabric_platform_update_domain_walk( # pylint: 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) - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async 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. 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: - ~azure.mgmt.compute.v2024_07_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. 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: - """ - @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 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 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_07_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 + :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_07_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4080,243 +3172,53 @@ async def convert_to_single_placement_group( } 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-07-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[_models.VirtualMachineImage] = 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, - 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 - - 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 _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, - 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-07-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, "OrchestrationServiceStateInput") - - _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_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, - 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("VirtualMachineImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # 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. 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_07_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. - - :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 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_set_orchestration_service_state( - self, - resource_group_name: str, - vm_scale_set_name: str, - parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[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_07_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 = 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-07-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._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 - ) - 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 VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long +class VirtualMachineImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_extensions` attribute. + :attr:`virtual_machine_images` attribute. """ models = _models @@ -4329,14 +3231,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_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 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_07_01.models.VmImagesInEdgeZoneListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4345,209 +3253,166 @@ 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-07-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[_models.VmImagesInEdgeZoneListResult] = 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_list_by_edge_zone_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("VmImagesInEdgeZoneListResult", 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_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 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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", 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) + + _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_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 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_07_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_07_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_07_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-07-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_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) - 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( - self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_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 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_07_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4556,205 +3421,144 @@ 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-07-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_list_skus_request( + location=location, + publisher_name=publisher_name, + offer=offer, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_07_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_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( + @distributed_trace_async + async def list( self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: IO[bytes], + location: str, + publisher_name: str, + offer: str, + skus: str, *, - content_type: str = "application/json", + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. + ) -> 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 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_07_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 + :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_07_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 {}) - @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. - - :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_07_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_07_01.models.VirtualMachineScaleSetExtension] - :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-07-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) + 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_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) - 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 _delete_initial( - self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncIterator[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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 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_07_01.models.VirtualMachineImage + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4767,12 +3571,14 @@ 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-07-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_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, @@ -4780,248 +3586,33 @@ 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) - - 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, - vm_scale_set_name: str, - vmss_extension_name: str, - *, - expand: Optional[str] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSetExtension: - """The operation to get 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 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_07_01.models.VirtualMachineScaleSetExtension - :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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = 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, - 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("VirtualMachineScaleSetExtension", 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. - - :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_07_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-07-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 - - 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) - - _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 VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. + :attr:`log_analytics` attribute. """ models = _models @@ -5034,8 +3625,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 _cancel_initial( - self, resource_group_name: str, vm_scale_set_name: str, **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, @@ -5045,17 +3636,28 @@ async def _cancel_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-07-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_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, ) @@ -5075,42 +3677,106 @@ async def _cancel_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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_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. + @overload + async def begin_export_request_rate_by_interval( + self, + location: str, + parameters: _models.RequestRateByIntervalInput, + *, + 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 - :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 parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. + Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 LogAnalyticsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.LogAnalyticsOperationResult] :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-07-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) + @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. + + :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 LogAnalyticsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.LogAnalyticsOperationResult] + :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. + + :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_07_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_07_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-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._cancel_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + 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, headers=_headers, params=_params, @@ -5119,27 +3785,34 @@ async def begin_cancel( 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("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: 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[None].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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( + 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 + async def _export_throttled_requests_initial( + self, location: str, body: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5149,17 +3822,28 @@ async 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-07-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_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(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "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, ) @@ -5179,44 +3863,103 @@ async def _start_os_upgrade_initial( except (StreamConsumedError, StreamClosedError): pass 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) + + 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_export_throttled_requests( + self, + location: str, + body: _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 name of Azure region. Required. + :type location: str + :param body: The request body. Required. + :type body: ~azure.mgmt.compute.v2024_07_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_07_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export_throttled_requests( + self, location: str, body: 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 name of Azure region. Required. + :type location: str + :param body: The request body. Required. + :type body: 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_07_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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 begin_export_throttled_requests( + self, location: str, body: 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 - :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 body: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] type. + Required. + :type body: ~azure.mgmt.compute.v2024_07_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_07_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-07-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, 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, + raw_result = await self._export_throttled_requests_initial( + location=location, + body=body, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -5225,28 +3968,67 @@ async def begin_start_os_upgrade( 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("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: 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[None].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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[_models.LogAnalyticsOperationResult]( + 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]: + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineExtensionImage] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5259,11 +4041,11 @@ 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-07-01")) - cls: ClsType[AsyncIterator[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, @@ -5271,23 +4053,18 @@ async 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 = 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("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5295,73 +4072,97 @@ 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 {}) - + async 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_07_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-07-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) + 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: 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]: + 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_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, 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_07_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_07_01.models.VirtualMachineExtensionImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5376,11 +4177,13 @@ 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-07-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, @@ -5399,7 +4202,7 @@ 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("VirtualMachineExtensionImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5407,14 +4210,14 @@ async 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_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vm_extensions` attribute. + :attr:`virtual_machine_run_commands` attribute. """ models = _models @@ -5427,15 +4230,24 @@ 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 - ) -> 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_07_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-07-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5444,218 +4256,72 @@ async 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-07-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_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) + 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) - _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, 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) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 AsyncItemPaged(get_next, extract_data) - return deserialized # type: ignore + @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. - @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. 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_07_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_07_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. 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_07_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. - - :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_07_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_07_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_07_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-07-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) - - 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: 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.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 _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, 404: ResourceNotFoundError, @@ -5664,38 +4330,23 @@ 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-07-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, "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 = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5703,173 +4354,180 @@ 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("RunCommandDocument", 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, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_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 + ) -> 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_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_07_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 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.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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_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. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 AsyncLROPoller that returns either VirtualMachineScaleSetVMExtension or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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 + + 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) @distributed_trace_async - async def begin_update( + async 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 - ) -> AsyncLROPoller[_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_07_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_07_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_07_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-07-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._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) + 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: 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.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 + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - async 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 + + 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, @@ -5879,19 +4537,30 @@ 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-07-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_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, ) @@ -5905,7 +4574,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, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -5913,46 +4582,128 @@ 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 == 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_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. + @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 - :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-07-01")) - cls: ClsType[None] = kwargs.pop("cls", 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_07_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_07_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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_07_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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. 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_07_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_07_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-07-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, 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._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, @@ -5961,52 +4712,39 @@ 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 + 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 + ) - @distributed_trace_async - async def get( + async 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_07_01.models.VirtualMachineScaleSetVMExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6015,26 +4753,37 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = 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_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 = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -6042,116 +4791,175 @@ async def get( 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 = 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_async - async def list( + @overload + async 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. + ) -> 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. 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_07_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_07_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 VirtualMachineRunCommand or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) + @overload + async 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 + ) -> AsyncLROPoller[_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 AsyncLROPoller that returns either VirtualMachineRunCommand or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineRunCommand] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _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( - "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_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_07_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_07_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-07-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, 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_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 + ) + 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_07_01.aio.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) -> 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.VirtualMachineRunCommand].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualMachineRunCommand]( + 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, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[ - Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] - ] = None, - **kwargs: Any + async def _delete_initial( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6161,33 +4969,18 @@ 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-07-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 - - _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, ) @@ -6201,7 +4994,7 @@ async 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: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6209,119 +5002,49 @@ 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( - 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. - - :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_07_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: - """ - - @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. - - :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: - """ - @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 + async def begin_delete( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> AsyncLROPoller[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_07_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 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-07-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( + 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_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, @@ -6335,7 +5058,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: @@ -6349,118 +5074,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 - 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, - 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-07-01")) - cls: ClsType[AsyncIterator[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 = 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) +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_07_01.aio.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) -> 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_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. + @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 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] + :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_07_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-07-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 + cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) - 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, @@ -6469,109 +5120,179 @@ async 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-07-01")) - cls: ClsType[AsyncIterator[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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + 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) - response = pipeline_response.http_response + 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")) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods + """ + .. 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 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] + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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_07_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-07-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) + 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: 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, + 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 ) - 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) + 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) + + @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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - 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, @@ -6580,116 +5301,77 @@ async 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-07-01")) - cls: ClsType[AsyncIterator[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 = 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, 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 - 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 AsyncItemPaged(get_next, extract_data) - @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. + @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. - :param resource_group_name: The name of the resource 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] + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-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._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 - ) - 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.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) - 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, - **kwargs: Any - ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6698,33 +5380,170 @@ async 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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[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, + 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) + + @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. + + :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_07_01.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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-07-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") + + _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) @@ -6737,7 +5556,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, 201]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6745,38 +5564,39 @@ 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 @overload - async def begin_update( + async 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 - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> 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 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_07_01.models.VirtualMachineScaleSetVM + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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. @@ -6788,37 +5608,33 @@ async 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 AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async 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 - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> 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 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 @@ -6831,37 +5647,34 @@ async 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 AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async 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 - ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> 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 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_07_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_07_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. @@ -6870,10 +5683,10 @@ async 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 AsyncLROPoller that returns either VirtualMachineScaleSetVM or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either VirtualMachineScaleSet or the result + of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -6881,15 +5694,14 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, 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._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, @@ -6904,35 +5716,38 @@ async 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: 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.VirtualMachineScaleSet].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.VirtualMachineScaleSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( + async 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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -6943,19 +5758,31 @@ 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-07-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_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, + 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, ) @@ -6969,7 +5796,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]: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -6977,53 +5804,149 @@ 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 = {} + 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_07_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_07_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_07_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def begin_delete( + async 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 - ) -> AsyncLROPoller[None]: - """Deletes a virtual machine from a VM scale set. + ) -> 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 - :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] + :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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-07-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._delete_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, - 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, @@ -7032,51 +5955,39 @@ 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 + 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 - - @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 AsyncLROPoller[_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. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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, @@ -7089,286 +6000,63 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[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 = 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("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_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. + 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. - :param resource_group_name: The name of the resource 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_07_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-07-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 = 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("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 - ) -> 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. - :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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-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 - - async 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, 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 _power_off_initial( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **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-07-01")) - cls: ClsType[AsyncIterator[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 = 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 - - @distributed_trace_async - async def begin_power_off( - self, - resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, - **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. - - :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 AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[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 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 {} @@ -7380,11 +6068,10 @@ async 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 = await self._power_off_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, - skip_shutdown=skip_shutdown, + force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -7399,7 +6086,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: @@ -7413,8 +6102,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 _restart_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, @@ -7424,18 +6117,32 @@ 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-07-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(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, ) @@ -7449,51 +6156,125 @@ async def _restart_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): pass 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) + + 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_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. - - :param resource_group_name: The name of the resource group. Required. + @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 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_07_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: """ - _headers = kwargs.pop("headers", {}) or {} + + @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_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. + + :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_07_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-07-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( + 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, @@ -7507,7 +6288,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: @@ -7521,8 +6304,143 @@ 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 _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + @overload + async 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_07_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. 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_07_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-07-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 + + 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 _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, @@ -7532,18 +6450,33 @@ async 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-07-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_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, ) @@ -7565,43 +6498,137 @@ 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 - ) -> AsyncLROPoller[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 + 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]: + """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_07_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 {} + + @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. + + :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 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. 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_07_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: + """ + _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-07-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( + raw_result = await 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, @@ -7615,7 +6642,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: @@ -7629,8 +6658,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 - async def _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + async 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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7640,18 +6675,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-07-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: + _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, ) @@ -7673,44 +6720,128 @@ 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 = {} + 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_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 + ) -> 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. + Required. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_07_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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 + ) -> 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. + 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 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_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 ) -> AsyncLROPoller[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_07_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 = 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-07-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._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, @@ -7724,7 +6855,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: @@ -7739,30 +6872,35 @@ 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( + 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, - 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_07_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_07_01.models.RecoveryWalkResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7777,14 +6915,15 @@ async 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-07-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, @@ -7802,58 +6941,7 @@ 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 - - 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, - 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-07-01")) - cls: ClsType[AsyncIterator[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 = 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) + deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7861,76 +6949,18 @@ async def _perform_maintenance_initial( 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 - ) -> 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 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-07-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 - - 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 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 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_07_01.models.VirtualMachineScaleSetInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7945,12 +6975,11 @@ async def simulate_eviction( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -7965,19 +6994,22 @@ async def simulate_eviction( 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 - async def _attach_detach_data_disks_initial( + 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.AttachDetachDataDisksRequest, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -7998,15 +7030,14 @@ 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_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, @@ -8036,6 +7067,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) @@ -8045,95 +7077,83 @@ async def _attach_detach_data_disks_initial( return deserialized # type: ignore @overload - async def begin_attach_detach_data_disks( + async 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 - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from 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 attach and detach data disks operation on a - Virtual Machine Scale Sets VM. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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 StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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.StorageProfile]: - """Attach and detach data disks to/from 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 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 AsyncLROPoller that returns either StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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 - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from 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 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_07_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_07_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_07_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 {}) @@ -8141,16 +7161,15 @@ async def begin_attach_detach_data_disks( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, 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._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, @@ -8161,11 +7180,9 @@ async def begin_attach_detach_data_disks( await 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: AsyncPollingMethod = cast( @@ -8176,22 +7193,105 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.StorageProfile].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.StorageProfile]( - 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 _run_command_initial( + @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_07_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-07-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 + + 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) + + _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 _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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8212,15 +7312,17 @@ 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") + 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, @@ -8247,99 +7349,105 @@ 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_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 - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> 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_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_07_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_07_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 RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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 - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> 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_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 AsyncLROPoller that returns either RunCommandResult or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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 - ) -> AsyncLROPoller[_models.RunCommandResult]: - """Run command on a virtual machine in a VM scale set. + ) -> 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_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_07_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_07_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_07_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 {}) @@ -8347,16 +7455,15 @@ async def begin_run_command( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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_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, @@ -8367,11 +7474,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( @@ -8382,43 +7487,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.RunCommandResult].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.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_07_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") + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_or_update_initial( + async 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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -8439,16 +7522,19 @@ 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_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, @@ -8466,7 +7552,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): @@ -8474,105 +7560,118 @@ 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_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 - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or 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. + :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_07_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_07_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_07_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_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 create or 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. + :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 AsyncLROPoller that returns either VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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 - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to create or 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. + :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_07_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_07_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_07_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 {}) @@ -8580,16 +7679,16 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._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, @@ -8600,36 +7699,29 @@ 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( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], - **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, @@ -8639,30 +7731,17 @@ 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-07-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, "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, ) @@ -8676,7 +7755,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): @@ -8684,125 +7763,47 @@ 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( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + @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. - :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_07_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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> 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_name: The name of the virtual machine where the extension should be 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 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 VirtualMachineExtension or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] + :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: """ - - @distributed_trace_async - 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.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_name: The name of the virtual machine where the extension should be 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 Update Virtual Machine Extension - operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. - :type extension_parameters: - ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineExtension] - :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-07-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._reapply_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, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -8811,31 +7812,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("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 _redeploy_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, @@ -8845,18 +7848,32 @@ 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-07-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_extensions_delete_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_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, ) @@ -8870,7 +7887,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): @@ -8878,44 +7895,117 @@ 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 + @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]: - """The operation to delete the extension. + """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 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_07_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_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. - :param resource_group_name: The name of the resource 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 deleted. + :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, + 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 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_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_07_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-07-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._redeploy_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_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, @@ -8929,7 +8019,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: @@ -8943,30 +8035,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 _reimage_initial( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - *, - expand: Optional[str] = None, + vm_scale_set_name: str, + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, 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_07_01.models.VirtualMachineExtension - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8975,206 +8050,199 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineExtension] = 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_get_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, - 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("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_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_07_01.models.VirtualMachineExtensionsListResult + @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. 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: + ~azure.mgmt.compute.v2024_07_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: """ - 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-07-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 = 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("VirtualMachineExtensionsListResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -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_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machines` attribute. - """ - - models = _models + @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. - 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_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 - 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_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 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_07_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_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_07_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 = 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-07-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._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) - 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_all_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 ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -9195,14 +8263,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_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_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, api_version=api_version, content_type=content_type, @@ -9229,94 +8300,99 @@ 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_all( 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 - ) -> 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 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 Capture Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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 VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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, *, 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 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 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 AsyncLROPoller that returns either VirtualMachineCaptureResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_all( 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 - ) -> 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 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 Capture Virtual Machine operation. Is either a - VirtualMachineCaptureParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_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 {}) @@ -9324,15 +8400,15 @@ async def begin_capture( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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_all_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, @@ -9343,11 +8419,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( @@ -9358,24 +8432,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 _restart_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 = { @@ -9396,17 +8465,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_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, @@ -9424,7 +8494,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): @@ -9432,142 +8502,112 @@ 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_restart( 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]: + """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 Create Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_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 create or update a virtual machine. Please note some properties can be set - only during virtual machine creation. + ) -> 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 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_07_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_restart( 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]: + """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 Create Virtual Machine operation. Is either a - VirtualMachine type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + :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_07_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-07-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._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, @@ -9578,37 +8618,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 _set_orchestration_service_state_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, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -9632,14 +8667,12 @@ async def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "VirtualMachineUpdate") + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") - _request = build_virtual_machines_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, @@ -9657,7 +8690,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): @@ -9665,121 +8698,93 @@ 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_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - parameters: _models.VirtualMachineUpdate, + 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 - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[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 Update Virtual Machine operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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 parameters: The input object for SetOrchestrationServiceState API. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_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 - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[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 Update 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 AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_set_orchestration_service_state( 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, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """The operation to update a virtual machine. + ) -> AsyncLROPoller[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 Update Virtual Machine operation. Is either a - VirtualMachineUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9787,17 +8792,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._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, @@ -9808,32 +8811,51 @@ 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 + + @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. 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.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) - 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, @@ -9842,22 +8864,105 @@ async def _delete_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-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _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) - _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) + 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("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) + + 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 _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, + 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-07-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_start_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 @@ -9867,7 +8972,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): @@ -9875,44 +8980,114 @@ 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 + @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_07_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_delete( - self, resource_group_name: str, vm_name: str, *, force_deletion: 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]: - """The operation to delete a virtual machine. + """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 force_deletion: Optional parameter to force delete virtual machines. 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 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_07_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-07-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._start_initial( resource_group_name=resource_group_name, - vm_name=vm_name, - force_deletion=force_deletion, + 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, @@ -9926,7 +9101,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: @@ -9940,31 +9117,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_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" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachine +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_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` 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.VirtualMachine"]: + """Gets all the virtual machines 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 VirtualMachine or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9973,100 +9163,96 @@ async def get( } 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-07-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 - ) + def prepare_request(next_link=None): + if not next_link: - response = pipeline_response.http_response + _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) - 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("VirtualMachine", pipeline_response.http_response) + async 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, 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 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. + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - :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_07_01.models.VirtualMachineInstanceView + return pipeline_response + + return AsyncItemPaged(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 + ) -> AsyncIterable["_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_07_01.models.ExpandTypesForListVMs + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-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.VirtualMachineListResult] = 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, @@ -10075,298 +9261,96 @@ 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 {}) + 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-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + _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) - _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) + 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 = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + async 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, 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, 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 - 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 AsyncItemPaged(get_next, extract_data) - @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. + @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. - :param resource_group_name: The name of the resource 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] + :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_07_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_07_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-07-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 - ) - 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_name: str, *, hibernate: 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-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - ) - _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 - - @distributed_trace_async - 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. - :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 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-07-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._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, - 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 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-07-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 - ) - - 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 - - @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. - - :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_07_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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10431,42 +9415,32 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_all( + @distributed_trace_async + async def get( self, + resource_group_name: str, + vm_name: str, *, - status_only: Optional[str] = None, - filter: Optional[str] = None, - expand: Optional[Union[str, _models.ExpandTypesForListVMs]] = None, + expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any - ) -> AsyncIterable["_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. + ) -> _models.VirtualMachine: + """Retrieves information about the model view or the instance view of a virtual machine. - :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_07_01.models.ExpandTypesForListVMs - :return: An iterator like instance of either VirtualMachine or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachine] + :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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: VirtualMachine or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10475,83 +9449,975 @@ def list_all( } 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 + + 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, + 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-07-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, "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, + ) + _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 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_07_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_07_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. + + :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_07_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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. 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_07_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_07_01.models.VirtualMachine] + :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-07-01")) + 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._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, + **kwargs + ) + 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) + 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.VirtualMachine].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 + ) + + 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, + 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-07-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, "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, + ) + _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]: + 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 + + @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_07_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_07_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_07_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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. 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_07_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_07_01.models.VirtualMachine] + :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-07-01")) + 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._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, + **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("VirtualMachine", 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.VirtualMachine].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 + ) + + 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, + 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-07-01")) + cls: ClsType[AsyncIterator[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 = 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, 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. 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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_name=vm_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 + + 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 - _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) + async def _assess_patches_initial( + self, resource_group_name: str, vm_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 {}) - 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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - async 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, AsyncList(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _request = build_virtual_machines_assess_patches_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 + _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 + + @distributed_trace_async + 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. 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_07_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-07-01")) + 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._assess_patches_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 ) - response = pipeline_response.http_response + 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("VirtualMachineAssessPatchesResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - return pipeline_response + 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.VirtualMachineAssessPatchesResult].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 _attach_detach_data_disks_initial( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, 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-07-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, "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, + ) + _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_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: _models.AttachDetachDataDisksRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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_07_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 StorageProfile or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageProfile]: + """Attach and detach data disks to/from the virtual machine. - 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_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 AsyncLROPoller that returns either StorageProfile or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ - @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. + @distributed_trace_async + async def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_name: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any + ) -> 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 - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :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_07_01.models.AttachDetachDataDisksRequest or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either StorageProfile or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineSize] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = 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, 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_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("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, 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 _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, 404: ResourceNotFoundError, @@ -10560,62 +10426,199 @@ 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") - 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) + _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, + ) + _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 + ) + + 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_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_07_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_07_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_07_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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. 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_07_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_07_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, 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( + 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 ) - 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) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - return pipeline_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized - return AsyncItemPaged(get_next, extract_data) + 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.VirtualMachineCaptureResult].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 + ) - async def _power_off_initial( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any + async def _convert_to_managed_disks_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10631,11 +10634,10 @@ async def _power_off_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_power_off_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, - skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, @@ -10658,30 +10660,30 @@ 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 == 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_power_off( - self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any + async def begin_convert_to_managed_disks( + self, resource_group_name: str, vm_name: str, **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. + """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 - :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: @@ -10695,10 +10697,9 @@ async 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 = await self._power_off_initial( + raw_result = await self._convert_to_managed_disks_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, @@ -10713,7 +10714,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: @@ -10727,7 +10730,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 _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + 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, 404: ResourceNotFoundError, @@ -10742,10 +10747,11 @@ async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwarg api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_reapply_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, @@ -10768,21 +10774,32 @@ 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 == 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_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_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 + :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: @@ -10796,9 +10813,10 @@ async def begin_reapply(self, resource_group_name: str, vm_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 = await self._reapply_initial( + raw_result = await 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, @@ -10813,7 +10831,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: @@ -10827,7 +10847,24 @@ 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 _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + @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, @@ -10840,13 +10877,70 @@ async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwarg _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 + ) + + 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, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, 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-07-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(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( 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, ) @@ -10868,38 +10962,120 @@ 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 = {} + 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. 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. + Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_07_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_07_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. 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. + 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_07_01.models.VirtualMachineInstallPatchesResult] + :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_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. - :param resource_group_name: The name of the resource 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 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_07_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_07_01.models.VirtualMachineInstallPatchesResult] :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-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._restart_initial( + raw_result = await self._install_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, + install_patches_input=install_patches_input, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -10908,26 +11084,46 @@ 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): + 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: 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.VirtualMachineInstallPatchesResult].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.VirtualMachineInstallPatchesResult]( + 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]: + @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_07_01.models.VirtualMachineInstanceView + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10940,9 +11136,9 @@ async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - _request = build_virtual_machines_start_request( + _request = build_virtual_machines_instance_view_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -10952,82 +11148,27 @@ async def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: ) _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("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # 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. - - :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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, **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]: + async def _perform_maintenance_initial( + self, resource_group_name: str, vm_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11042,7 +11183,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-07-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_redeploy_request( + _request = build_virtual_machines_perform_maintenance_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11068,18 +11209,26 @@ 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_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 @@ -11096,7 +11245,7 @@ async def begin_redeploy(self, resource_group_name: str, vm_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 = await self._redeploy_initial( + raw_result = await self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -11113,7 +11262,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: @@ -11127,12 +11278,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 _reimage_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any + 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, @@ -11142,32 +11289,18 @@ 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-07-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, "VirtualMachineReimageParameters") - else: - _json = None - - _request = build_virtual_machines_reimage_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, ) @@ -11189,120 +11322,52 @@ 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 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. 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_07_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. 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: - """ + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def begin_reimage( - self, - resource_group_name: str, - vm_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **kwargs: Any + async def begin_power_off( + self, resource_group_name: str, vm_name: str, *, skip_shutdown: Optional[bool] = 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. + """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 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_07_01.models.VirtualMachineReimageParameters 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 {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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( + raw_result = await self._power_off_initial( resource_group_name=resource_group_name, vm_name=vm_name, - parameters=parameters, + skip_shutdown=skip_shutdown, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -11316,7 +11381,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: @@ -11330,75 +11397,7 @@ 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( - 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_07_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-07-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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _perform_maintenance_initial( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + async def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11413,7 +11412,7 @@ async def _perform_maintenance_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_perform_maintenance_request( + _request = build_virtual_machines_reapply_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11439,20 +11438,24 @@ 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_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to perform maintenance on a virtual machine. + 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 resource_group_name: The name of the resource 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 @@ -11469,7 +11472,7 @@ async def begin_perform_maintenance( 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._reapply_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -11486,7 +11489,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: @@ -11500,59 +11505,7 @@ 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 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-07-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 - ) - - 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( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: + async def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11567,7 +11520,7 @@ async def _assess_patches_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_assess_patches_request( + _request = build_virtual_machines_redeploy_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11593,39 +11546,41 @@ 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( - self, resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: - """Assess patches on the VM. + 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 resource_group_name: The name of the resource 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_07_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-07-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._redeploy_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -11637,11 +11592,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( @@ -11652,21 +11605,19 @@ 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 - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _install_patches_initial( + async def _reimage_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncIterator[bytes]: error_map: MutableMapping = { @@ -11687,12 +11638,15 @@ async def _install_patches_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") + if parameters is not None: + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") + else: + _json = None - _request = build_virtual_machines_install_patches_request( + _request = build_virtual_machines_reimage_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -11721,94 +11675,110 @@ 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( + async def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. 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. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesParameters + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.v2024_07_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 VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesResult] + :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_install_patches( + async def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: IO[bytes], + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. 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. - Required. - :type install_patches_input: IO[bytes] + :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 VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesResult] + :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_install_patches( + async def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. 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_07_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_07_01.models.VirtualMachineInstallPatchesResult] + :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_07_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 {}) @@ -11816,15 +11786,15 @@ async def begin_install_patches( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._reimage_initial( resource_group_name=resource_group_name, vm_name=vm_name, - install_patches_input=install_patches_input, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -11835,11 +11805,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( @@ -11850,23 +11818,15 @@ 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 - async def _attach_detach_data_disks_initial( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: + async def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11875,29 +11835,17 @@ async 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-07-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, "AttachDetachDataDisksRequest") - - _request = build_virtual_machines_attach_detach_data_disks_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, ) @@ -11922,6 +11870,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) @@ -11930,104 +11879,32 @@ async def _attach_detach_data_disks_initial( return deserialized # type: ignore - @overload - async def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: _models.AttachDetachDataDisksRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the 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 - :param parameters: Parameters supplied to the attach and detach data disks operation on the - virtual machine. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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 StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the 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 - :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 StorageProfile or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def begin_attach_detach_data_disks( - self, - resource_group_name: str, - vm_name: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from the virtual machine. + async def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> AsyncLROPoller[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 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_07_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_07_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: """ - _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-07-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, 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._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, @@ -12036,11 +11913,9 @@ async def begin_attach_detach_data_disks( await 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: AsyncPollingMethod = cast( @@ -12051,16 +11926,81 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.StorageProfile].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.StorageProfile]( - 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_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. 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_07_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-07-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) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + async def _run_command_initial( self, resource_group_name: str, @@ -12120,10 +12060,15 @@ 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 @@ -12139,7 +12084,8 @@ async def begin_run_command( ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command 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 @@ -12167,14 +12113,15 @@ async def begin_run_command( ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command 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 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". + Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns either RunCommandResult or the result of cls(response) @@ -12193,7 +12140,8 @@ async def begin_run_command( ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command 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 @@ -12255,237 +12203,17 @@ def get_long_running_output(pipeline_response): 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_07_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_07_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-07-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 = 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("VirtualMachineImage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :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_07_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-07-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 - - return deserialized # 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. - - :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_07_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-07-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 = 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 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 simulate_eviction(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 - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_07_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 = { @@ -12500,10 +12228,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-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_publishers_request( - location=location, + _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, @@ -12518,33 +12247,14 @@ async def list_publishers(self, location: str, **kwargs: Any) -> List[_models.Vi 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_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. + return cls(pipeline_response, None, {}) # 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 - :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_07_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, @@ -12557,12 +12267,11 @@ async 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-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", 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, + _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, @@ -12570,38 +12279,112 @@ async def list_skus( ) _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_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_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 - :return: VmImagesInEdgeZoneListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.VmImagesInEdgeZoneListResult + :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-07-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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12610,49 +12393,170 @@ async def list_by_edge_zone( } 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_07_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_07_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-07-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - _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) + 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("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 VirtualMachineImagesEdgeZoneOperations: +class ProximityPlacementGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. + :attr:`proximity_placement_groups` attribute. """ models = _models @@ -12665,28 +12569,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, 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. + @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 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_07_01.models.VirtualMachineImage + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12695,81 +12593,161 @@ async def get( } 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) + + 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("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) + + 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.ProximityPlacementGroup"]: + """Lists all proximity placement groups in 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 ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroupListResult] = 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) + 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_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) - 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("VirtualMachineImage", pipeline_response.http_response) + 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) - 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 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. + 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 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_07_01.models.VirtualMachineImageResource] + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async 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 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_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12784,18 +12762,13 @@ 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-07-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_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, + _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, - expand=expand, - top=top, - orderby=orderby, + include_colocation_status=include_colocation_status, api_version=api_version, headers=_headers, params=_params, @@ -12813,28 +12786,89 @@ 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("[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 + async 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. + + :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_07_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_07_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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_07_01.models.ProximityPlacementGroup + :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 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 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_07_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 + :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_07_01.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12845,18 +12879,29 @@ async def list_offers( } 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-07-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.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - 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, "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, ) @@ -12869,29 +12914,94 @@ async def list_offers( 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("[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 + async 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_07_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_07_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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_07_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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. + async 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 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_07_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 + :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_07_01.models.ProximityPlacementGroupUpdate or + IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12902,17 +13012,29 @@ async def list_publishers( } 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-07-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.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, + 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, ) @@ -12929,7 +13051,7 @@ async def list_publishers( 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 @@ -12937,22 +13059,16 @@ async def list_publishers( 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 delete(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 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_07_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 + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12967,13 +13083,11 @@ async 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-07-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_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, + _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, api_version=api_version, headers=_headers, @@ -12992,22 +13106,18 @@ async 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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore -class VirtualMachineExtensionImagesOperations: +class RestorePointCollectionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. + :attr:`restore_point_collections` attribute. """ models = _models @@ -13020,24 +13130,24 @@ 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_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. - :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_07_01.models.VirtualMachineExtensionImage + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13046,56 +13156,77 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + _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_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("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) - 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(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections 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_07_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 RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13104,68 +13235,82 @@ 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-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + _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) - _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("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) - 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, - *, - 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 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_07_01.models.VirtualMachineExtensionImage] + 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. 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 + :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_07_01.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13180,16 +13325,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-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_list_versions_request( - location=location, - publisher_name=publisher_name, - type=type, + _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, - filter=filter, - top=top, - orderby=orderby, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -13207,57 +13349,40 @@ 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("RestorePointCollection", 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_07_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, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13265,25 +13390,29 @@ async def create_or_update( async def create_or_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 - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :param parameters: Parameters supplied to the Create Availability Set operation. Required. + :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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13291,21 +13420,24 @@ 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]], + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollection, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :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_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13321,7 +13453,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -13329,11 +13461,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, "RestorePointCollection") - _request = build_availability_sets_create_or_update_request( + _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, @@ -13351,11 +13483,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("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -13366,25 +13498,27 @@ async def create_or_update( async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySetUpdate + :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_07_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13392,25 +13526,27 @@ async def update( 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 - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Required. + :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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -13418,21 +13554,23 @@ async def update( async def update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollectionUpdate or + IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13448,7 +13586,7 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -13456,11 +13594,11 @@ async def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - _request = build_availability_sets_update_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, @@ -13482,25 +13620,16 @@ 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("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore 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. - - :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 - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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, @@ -13513,11 +13642,11 @@ async def delete(self, resource_group_name: str, availability_set_name: str, **k _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_availability_sets_delete_request( + _request = build_restore_point_collections_delete_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, headers=_headers, @@ -13525,93 +13654,129 @@ async def delete(self, resource_group_name: str, availability_set_name: str, **k ) _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, 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, 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, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: - """Retrieves information about an availability set. + 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. 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_07_01.models.AvailabilitySet + :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: """ - 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-07-01")) - cls: ClsType[_models.AvailabilitySet] = 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._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) - _request = build_availability_sets_get_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) + 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 SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` 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_subscription( - self, *, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. + 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. - :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 SshPublicKeyResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13624,9 +13789,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_ssh_public_keys_list_by_subscription_request( subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -13651,7 +13815,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -13675,21 +13839,26 @@ 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_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. + :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 SshPublicKeyResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13702,7 +13871,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_ssh_public_keys_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, @@ -13729,7 +13898,7 @@ def prepare_request(next_link=None): return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -13752,28 +13921,21 @@ 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, 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 - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineSize] + :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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13782,154 +13944,114 @@ def list_available_sizes( } error_map.update(kwargs.pop("error_map", {}) or {}) - 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, - 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 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 + _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-07-01")) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - return pipeline_response + _request = build_ssh_public_keys_get_request( + resource_group_name=resource_group_name, + ssh_public_key_name=ssh_public_key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return AsyncItemPaged(get_next, extract_data) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response -class ProximityPlacementGroupsOperations: - """ - .. 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_07_01.aio.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ + deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) - models = _models + if cls: + return cls(pipeline_response, 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") + return deserialized # type: ignore @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_07_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_07_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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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]], + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyResource, IO[bytes]], **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. + :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_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13945,7 +14067,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -13953,11 +14075,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, @@ -13979,7 +14101,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 @@ -13990,26 +14112,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_07_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_07_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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -14017,26 +14139,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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -14044,22 +14166,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_07_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_07_01.models.SshPublicKeyUpdateResource or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14075,7 +14198,7 @@ async def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -14083,11 +14206,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, @@ -14109,7 +14232,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 @@ -14117,13 +14240,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: @@ -14142,9 +14266,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-07-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, @@ -14159,33 +14283,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_07_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_07_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_07_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_07_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_07_01.models.SshGenerateKeyPairInputParameters or + IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14196,18 +14381,32 @@ 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-07-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) + + 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_proximity_placement_groups_get_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, - include_colocation_status=include_colocation_status, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -14224,28 +14423,56 @@ 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("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 + +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` 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.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. + 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. - :return: An iterator like instance of either ProximityPlacementGroup 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 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_07_01.models.ProximityPlacementGroup] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14258,7 +14485,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Proximit def prepare_request(next_link=None): if not next_link: - _request = build_proximity_placement_groups_list_by_subscription_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, @@ -14284,7 +14513,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 @@ -14307,26 +14536,86 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @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. + @distributed_trace_async + async def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + *, + expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, + **kwargs: Any + ) -> _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 - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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_07_01.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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 {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + + _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, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: Union[_models.CapacityReservation, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14335,159 +14624,218 @@ def list_by_resource_group( } 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 - - 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) + _headers = case_insensitive_dict(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-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + 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") - 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_capacity_reservations_create_or_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return pipeline_response + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 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) -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + 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")) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_01.aio.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - models = _models + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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") + return deserialized # type: ignore @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservation, *, 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). + ) -> 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 Create Dedicated Host Group. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_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: - """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). + ) -> 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 Create Dedicated Host Group. 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_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( + async def begin_create_or_update( 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). + ) -> 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 Create Dedicated Host Group. Is either a - DedicatedHostGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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-07-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, @@ -14501,7 +14849,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -14509,11 +14857,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, "CapacityReservationUpdate") - _request = build_dedicated_host_groups_create_or_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, @@ -14524,163 +14873,182 @@ 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("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 update( + async def begin_update( self, resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DedicatedHostGroup: - """Update an dedicated host group. + ) -> 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 - :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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 Update capacity reservation operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_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 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. 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_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async 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. + ) -> 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 - :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_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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-07-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, 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_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 = 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]: - 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_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 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: - """ + async def _delete_initial( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14693,11 +15061,12 @@ async def delete(self, resource_group_name: str, host_group_name: str, **kwargs: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[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, @@ -14705,106 +15074,143 @@ async def delete(self, resource_group_name: str, host_group_name: str, **kwargs: ) _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, 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, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def get( + async 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. + ) -> 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 - :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" and "userData". - Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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: """ - 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-07-01")) - cls: ClsType[_models.DedicatedHostGroup] = 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._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) - _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 = 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 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_07_01.aio.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) -> 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.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 + ) -> 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. - :param resource_group_name: The name of the 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) + :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_07_01.models.DedicatedHostGroup] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14817,8 +15223,9 @@ def list_by_resource_group( 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, @@ -14844,7 +15251,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 @@ -14867,22 +15274,33 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @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. + @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. - :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14891,78 +15309,41 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Dedicate } 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 - - 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 - ) - 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-07-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 AsyncItemPaged(get_next, extract_data) + _stream = False + pipeline_response: PipelineResponse = await 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_07_01.aio.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) -> 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 deserialized # type: ignore async def _create_or_update_initial( self, @@ -15025,10 +15406,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 @@ -15045,11 +15431,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_07_01.models.DedicatedHost @@ -15076,11 +15463,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] @@ -15105,11 +15493,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. @@ -15152,7 +15541,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: @@ -15229,10 +15620,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 @@ -15249,11 +15644,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_07_01.models.DedicatedHostUpdate @@ -15280,11 +15676,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] @@ -15309,11 +15706,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. @@ -15350,13 +15748,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: @@ -15416,10 +15821,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 @@ -15429,7 +15839,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 @@ -15462,115 +15873,50 @@ async def begin_delete( 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" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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-07-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 + if cls: + return cls(pipeline_response, None, {}) # type: ignore - 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[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_07_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-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15583,9 +15929,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, @@ -15611,7 +15958,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 @@ -15634,6 +15981,126 @@ 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-07-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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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-07-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]: @@ -15678,10 +16145,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 @@ -15694,7 +16165,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 @@ -15731,7 +16203,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: @@ -15745,8 +16219,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_07_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_07_01.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -15756,18 +16326,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-07-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, ) @@ -15781,7 +16363,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): @@ -15791,6 +16373,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) @@ -15799,192 +16382,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_07_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_07_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-07-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_07_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-07-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) - - -class SshPublicKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_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. + @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. - :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_07_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_07_01.models.SshPublicKeyResource] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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-07-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, @@ -15993,213 +16539,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-07-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_07_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-07-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_07_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_07_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_07_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_07_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_07_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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, @@ -16208,126 +16676,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-07-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_07_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_07_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-07-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_07_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_07_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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, @@ -16336,64 +16790,112 @@ async def 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-07-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") - - _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-07-01")) + cls: ClsType[AsyncIterator[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 = 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-07-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, @@ -16406,11 +16908,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-07-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, @@ -16418,32 +16920,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_07_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-07-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_07_01.models.RollingUpgradeStatusInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -16458,11 +17032,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-07-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, @@ -16481,91 +17055,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_07_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_07_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-07-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) - if cls: - return cls(pipeline_response, 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 - return 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) - @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. + async def get_next(next_link=None): + _request = prepare_request(next_link) - :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_07_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_07_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - @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. + 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 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_07_01.models.SshPublicKeyGenerateKeyPairResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + return pipeline_response + + 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_07_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSetExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -16576,32 +17201,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-07-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, ) @@ -16618,36 +17230,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_07_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, @@ -16667,14 +17263,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, @@ -16701,10 +17298,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 @@ -16712,25 +17314,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -16738,43 +17348,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_07_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_07_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. + 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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -16782,15 +17410,16 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -16802,33 +17431,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 = { @@ -16849,14 +17481,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, @@ -16883,10 +17516,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 @@ -16894,25 +17532,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -16920,25 +17566,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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -16946,21 +17599,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -16968,15 +17629,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -16988,29 +17650,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, @@ -17025,9 +17691,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-07-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, @@ -17051,21 +17718,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: @@ -17081,7 +17758,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, @@ -17092,99 +17770,86 @@ async def begin_delete(self, resource_group_name: str, image_name: str, **kwargs 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_07_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-07-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) + 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_07_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_07_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_07_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-07-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -17197,9 +17862,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, @@ -17224,7 +17893,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 @@ -17247,21 +17916,33 @@ 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_07_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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17270,160 +17951,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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_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_07_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17437,7 +18011,7 @@ async def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -17445,12 +18019,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, @@ -17460,156 +18037,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_07_01.models.RestorePointCollectionUpdate + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_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_07_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_07_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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-07-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, @@ -17625,10 +18264,12 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -17651,24 +18292,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: @@ -17684,7 +18341,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, @@ -17699,7 +18358,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: @@ -17713,30 +18374,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_07_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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, @@ -17749,221 +18389,113 @@ 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-07-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_07_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-07-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_07_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-07-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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_07_01.aio.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 = { @@ -17987,12 +18519,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, @@ -18011,7 +18543,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): @@ -18019,99 +18551,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_07_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_07_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_07_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.RestorePoint] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.StorageProfile] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -18119,15 +18663,15 @@ async def begin_create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -18140,30 +18684,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, @@ -18179,10 +18725,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -18198,7 +18744,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): @@ -18206,25 +18752,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. + :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 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: @@ -18238,10 +18792,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, @@ -18256,7 +18810,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: @@ -18271,28 +18827,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_07_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSetVMInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18307,14 +18855,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-07-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, @@ -18332,246 +18879,268 @@ 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 + 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, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) -class CapacityReservationGroupsOperations: - """ - .. 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_07_01.aio.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - models = _models + _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) - 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") + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - @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. + response = pipeline_response.http_response - :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_07_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_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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) - @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. + 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 - :param resource_group_name: The name of the resource group. Required. + @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. 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_07_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 + :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 {}) - @distributed_trace_async - async def create_or_update( + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 + + 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.CapacityReservationGroup, IO[bytes]], + vm_scale_set_name: str, + instance_id: str, + *, + skip_shutdown: Optional[bool] = None, **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_07_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> 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-07-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") + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_capacity_reservation_groups_create_or_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-07-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _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, 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( + @distributed_trace_async + async def begin_power_off( self, resource_group_name: str, - capacity_reservation_group_name: str, - parameters: _models.CapacityReservationGroupUpdate, + vm_scale_set_name: str, + instance_id: str, *, - content_type: str = "application/json", + 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. + ) -> 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. - :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_07_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_07_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 + :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 {}) - @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-07-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) - :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_07_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( - self, - resource_group_name: str, - capacity_reservation_group_name: str, - parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], - **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. + 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 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_07_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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, @@ -18580,131 +19149,122 @@ 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-07-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_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, - 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_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. 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 + :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-07-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) - _request = build_capacity_reservation_groups_delete_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) - - _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) + 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 - @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_07_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18713,172 +19273,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-07-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_07_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_07_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_07_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-07-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 - - return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_by_subscription( + @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, *, - expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, - resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = None, + content_type: str = "application/json", **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_07_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_07_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_07_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. + 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_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. + + :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_07_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-07-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, @@ -18887,88 +19482,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-07-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_07_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-07-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, @@ -18978,30 +19599,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-07-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, ) @@ -19015,7 +19624,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): @@ -19023,124 +19632,49 @@ 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, - 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. - - :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_07_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_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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. - - :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_07_01.models.CapacityReservation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @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_07_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_07_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-07-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, @@ -19149,35 +19683,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_07_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-07-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 = { @@ -19201,12 +19805,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, @@ -19233,99 +19837,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_07_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_07_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_07_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.CapacityReservation] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -19333,15 +19945,15 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -19354,34 +19966,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-07-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, @@ -19397,10 +20063,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -19416,7 +20082,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): @@ -19424,31 +20090,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: @@ -19462,10 +20128,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, @@ -19475,50 +20141,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_07_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_07_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-07-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 + ) - 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 + 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_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_07_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSetVMExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19533,12 +20294,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-07-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, @@ -19558,35 +20320,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_07_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-07-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, @@ -19595,83 +20344,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-07-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_07_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_07_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_07_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_07_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_07_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_07_01.aio.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -19691,13 +20584,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, @@ -19716,7 +20612,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): @@ -19724,79 +20620,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_07_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_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -19804,14 +20741,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-07-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, @@ -19823,33 +20763,37 @@ async 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: 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, @@ -19859,28 +20803,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-07-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, ) @@ -19894,7 +20829,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): @@ -19902,93 +20837,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_07_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_07_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_07_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_07_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_07_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-07-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, @@ -19997,41 +20891,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_07_01.aio.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models @@ -20045,22 +20934,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_07_01.models.RunCommandDocumentBase] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20073,9 +20977,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, @@ -20100,7 +21007,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 @@ -20124,15 +21031,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_07_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_07_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20147,12 +21070,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-07-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, @@ -20170,7 +21096,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 @@ -20180,7 +21106,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 @@ -20208,9 +21135,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, @@ -20238,10 +21166,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 @@ -20249,21 +21182,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. @@ -20282,27 +21218,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) @@ -20315,19 +21254,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. @@ -20350,7 +21292,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, @@ -20370,7 +21313,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: @@ -20389,7 +21334,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 @@ -20417,9 +21363,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, @@ -20447,10 +21394,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 @@ -20458,24 +21409,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_07_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -20491,27 +21444,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) @@ -20524,22 +21479,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_07_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualMachineRunCommand or the @@ -20560,7 +21518,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, @@ -20574,13 +21533,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: @@ -20597,7 +21563,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, @@ -20613,9 +21579,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -20640,25 +21607,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] @@ -20675,7 +21649,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, @@ -20691,7 +21666,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: @@ -20705,28 +21682,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_07_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_07_01.models.VirtualMachineRunCommand + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20741,12 +21732,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-07-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, @@ -20766,37 +21756,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_07_01.models.VirtualMachineRunCommand] + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20805,89 +21796,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-07-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_07_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 = { @@ -20908,16 +21858,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, @@ -20944,10 +21893,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 @@ -20955,34 +21909,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -20990,34 +21942,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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -21025,29 +21975,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -21055,17 +22004,16 @@ async def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -21077,35 +22025,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 = { @@ -21126,16 +22075,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, @@ -21162,10 +22110,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 @@ -21173,34 +22125,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -21208,65 +22159,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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -21274,17 +22221,16 @@ async def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -21296,30 +22242,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, @@ -21335,11 +22288,10 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -21363,27 +22315,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: @@ -21399,9 +22355,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, @@ -21416,7 +22371,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: @@ -21429,171 +22386,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_07_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-07-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_07_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-07-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_07_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/__init__.py index 671f80ca3ffc..d12722e87c1c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/__init__.py @@ -43,7 +43,6 @@ CapacityReservationProfile, CapacityReservationUpdate, CapacityReservationUtilization, - ComputeOperationListResult, ComputeOperationValue, DataDisk, DataDiskImage, @@ -72,6 +71,9 @@ DiskRestorePointInstanceView, DiskRestorePointReplicationStatus, EncryptionIdentity, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, EventGridAndResourceGraph, ExtendedLocation, HardwareProfile, @@ -106,6 +108,9 @@ OSImageNotificationProfile, OSProfile, OSProfileProvisioningData, + Operation, + OperationDisplay, + OperationListResult, OrchestrationServiceStateInput, OrchestrationServiceSummary, PatchInstallationDetail, @@ -126,8 +131,10 @@ ResilientVMCreationPolicy, ResilientVMDeletionPolicy, Resource, + ResourceAutoGenerated, ResourceSharingProfile, ResourceWithOptionalLocation, + ResourceWithOptionalLocationAutoGenerated, RestorePoint, RestorePointCollection, RestorePointCollectionListResult, @@ -137,8 +144,8 @@ RestorePointInstanceView, RestorePointSourceMetadata, RestorePointSourceVMDataDisk, - RestorePointSourceVMOSDisk, RestorePointSourceVMStorageProfile, + RestorePointSourceVmosDisk, RetrieveBootDiagnosticsDataResult, RollbackStatusInfo, RollingUpgradePolicy, @@ -177,8 +184,10 @@ SubResourceReadOnly, SubResourceWithColocationStatus, SystemData, + SystemDataAutoGenerated, TerminateNotificationProfile, ThrottledRequestsInput, + TrackedResource, UefiSettings, UpdateResource, UpgradeOperationHistoricalStatusInfo, @@ -188,6 +197,7 @@ Usage, UsageName, UserAssignedIdentitiesValue, + UserAssignedIdentitiesValueAutoGenerated, UserInitiatedReboot, UserInitiatedRedeploy, VMDiskSecurityProfile, @@ -294,6 +304,7 @@ ) from ._compute_management_client_enums import ( # type: ignore + ActionType, AllocationStrategy, AlternativeType, ArchitectureTypes, @@ -302,6 +313,7 @@ CapacityReservationGroupInstanceViewTypes, CapacityReservationInstanceViewTypes, ConsistencyModeTypes, + CreatedByType, DedicatedHostLicenseTypes, DeleteOptions, DiffDiskOptions, @@ -340,6 +352,7 @@ OrchestrationServiceNames, OrchestrationServiceState, OrchestrationServiceStateAction, + Origin, PatchAssessmentState, PatchInstallationState, PatchOperationStatus, @@ -415,7 +428,6 @@ "CapacityReservationProfile", "CapacityReservationUpdate", "CapacityReservationUtilization", - "ComputeOperationListResult", "ComputeOperationValue", "DataDisk", "DataDiskImage", @@ -444,6 +456,9 @@ "DiskRestorePointInstanceView", "DiskRestorePointReplicationStatus", "EncryptionIdentity", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "EventGridAndResourceGraph", "ExtendedLocation", "HardwareProfile", @@ -478,6 +493,9 @@ "OSImageNotificationProfile", "OSProfile", "OSProfileProvisioningData", + "Operation", + "OperationDisplay", + "OperationListResult", "OrchestrationServiceStateInput", "OrchestrationServiceSummary", "PatchInstallationDetail", @@ -498,8 +516,10 @@ "ResilientVMCreationPolicy", "ResilientVMDeletionPolicy", "Resource", + "ResourceAutoGenerated", "ResourceSharingProfile", "ResourceWithOptionalLocation", + "ResourceWithOptionalLocationAutoGenerated", "RestorePoint", "RestorePointCollection", "RestorePointCollectionListResult", @@ -509,8 +529,8 @@ "RestorePointInstanceView", "RestorePointSourceMetadata", "RestorePointSourceVMDataDisk", - "RestorePointSourceVMOSDisk", "RestorePointSourceVMStorageProfile", + "RestorePointSourceVmosDisk", "RetrieveBootDiagnosticsDataResult", "RollbackStatusInfo", "RollingUpgradePolicy", @@ -549,8 +569,10 @@ "SubResourceReadOnly", "SubResourceWithColocationStatus", "SystemData", + "SystemDataAutoGenerated", "TerminateNotificationProfile", "ThrottledRequestsInput", + "TrackedResource", "UefiSettings", "UpdateResource", "UpgradeOperationHistoricalStatusInfo", @@ -560,6 +582,7 @@ "Usage", "UsageName", "UserAssignedIdentitiesValue", + "UserAssignedIdentitiesValueAutoGenerated", "UserInitiatedReboot", "UserInitiatedRedeploy", "VMDiskSecurityProfile", @@ -663,6 +686,7 @@ "WindowsConfiguration", "WindowsParameters", "WindowsVMGuestPatchAutomaticByPlatformSettings", + "ActionType", "AllocationStrategy", "AlternativeType", "ArchitectureTypes", @@ -671,6 +695,7 @@ "CapacityReservationGroupInstanceViewTypes", "CapacityReservationInstanceViewTypes", "ConsistencyModeTypes", + "CreatedByType", "DedicatedHostLicenseTypes", "DeleteOptions", "DiffDiskOptions", @@ -709,6 +734,7 @@ "OrchestrationServiceNames", "OrchestrationServiceState", "OrchestrationServiceStateAction", + "Origin", "PatchAssessmentState", "PatchInstallationState", "PatchOperationStatus", diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_compute_management_client_enums.py index eb5c4c5f024e..b2103a2f466f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_compute_management_client_enums.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -10,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. @@ -76,6 +83,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.** @@ -166,8 +182,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" @@ -284,8 +300,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'. """ @@ -409,7 +425,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): @@ -427,6 +442,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_07_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_models_py3.py index ecc47cd12635..2ccc8e69dfc4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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): @@ -477,28 +470,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_07_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_07_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}, } @@ -506,26 +547,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 @@ -540,16 +579,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_07_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 @@ -576,6 +620,7 @@ class AvailabilitySet(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "statuses": {"readonly": True}, } @@ -584,8 +629,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"}, @@ -609,10 +655,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 @@ -634,7 +680,7 @@ def __init__( :paramtype scheduled_events_policy: ~azure.mgmt.compute.v2024_07_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 @@ -962,23 +1008,28 @@ 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_07_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 @@ -1018,6 +1069,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}, @@ -1033,8 +1085,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"}, @@ -1056,10 +1109,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 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 @@ -1073,7 +1126,7 @@ def __init__( capacity reservation to be in same zone. :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 @@ -1085,7 +1138,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 @@ -1095,16 +1148,21 @@ 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_07_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 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 @@ -1135,6 +1193,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}, @@ -1145,8 +1204,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]"}, @@ -1164,10 +1224,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 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 @@ -1181,7 +1241,7 @@ def __init__( more details. :paramtype sharing_profile: ~azure.mgmt.compute.v2024_07_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 @@ -1581,29 +1641,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_07_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. @@ -1714,8 +1751,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_07_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 @@ -1815,8 +1852,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_07_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 @@ -1992,23 +2029,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_07_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_07_01.models.Sku @@ -2042,9 +2084,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}, @@ -2057,8 +2099,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"}, @@ -2083,10 +2126,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_07_01.models.Sku @@ -2103,7 +2146,7 @@ def __init__( :paramtype license_type: str or ~azure.mgmt.compute.v2024_07_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 @@ -2170,7 +2213,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. @@ -2179,16 +2222,21 @@ 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_07_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 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. @@ -2215,6 +2263,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}, @@ -2225,8 +2274,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]"}, @@ -2250,10 +2300,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 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. @@ -2270,7 +2320,7 @@ def __init__( :paramtype additional_capabilities: ~azure.mgmt.compute.v2024_07_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 @@ -2589,19 +2639,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): @@ -2643,7 +2699,6 @@ class DedicatedHostUpdate(UpdateResource): """ _validation = { - "platform_fault_domain": {"minimum": 0}, "host_id": {"readonly": True}, "virtual_machines": {"readonly": True}, "provisioning_time": {"readonly": True}, @@ -3074,6 +3129,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_07_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.compute.v2024_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.v2024_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.v2024_07_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class EventGridAndResourceGraph(_serialization.Model): """Specifies eventGridAndResourceGraph related Scheduled Event related configurations. @@ -3256,7 +3403,7 @@ def __init__( self.vm_size_properties = vm_size_properties -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. @@ -3265,16 +3412,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_07_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_07_01.models.ExtendedLocation :ivar source_virtual_machine: The source virtual machine from which Image is created. @@ -3296,6 +3448,7 @@ class Image(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, } @@ -3304,8 +3457,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"}, @@ -3325,10 +3479,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_07_01.models.ExtendedLocation :keyword source_virtual_machine: The source virtual machine from which Image is created. @@ -3343,7 +3497,7 @@ def __init__( :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2024_07_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 @@ -4813,13 +4967,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_07_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_07_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_07_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_07_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_07_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_07_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_07_01.models.OrchestrationServiceStateAction @@ -4843,8 +5117,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_07_01.models.OrchestrationServiceNames :keyword action: The action to be performed. Required. Known values are: "Resume" and @@ -4862,8 +5135,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_07_01.models.OrchestrationServiceNames :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", and "Suspended". @@ -5546,8 +5818,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 = { @@ -5575,23 +5846,28 @@ 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_07_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 zones: Specifies the Availability Zone where virtual machine, virtual machine scale set or availability set associated with the proximity placement group can be created. :vartype zones: list[str] @@ -5622,6 +5898,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}, @@ -5632,8 +5909,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]"}, @@ -5658,10 +5936,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 zones: Specifies the Availability Zone where virtual machine, virtual machine scale set or availability set associated with the proximity placement group can be created. :paramtype zones: list[str] @@ -5676,7 +5954,7 @@ def __init__( :paramtype intent: ~azure.mgmt.compute.v2024_07_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 @@ -5800,39 +6078,25 @@ def __init__( self.key_incarnation_id = key_incarnation_id -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_07_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. @@ -6108,14 +6372,63 @@ class ResilientVMDeletionPolicy(_serialization.Model): "enabled": {"key": "enabled", "type": "bool"}, } - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Specifies whether resilient VM deletion should be enabled on the virtual + machine scale set. The default value is false. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + 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 enabled: Specifies whether resilient VM deletion should be enabled on the virtual - machine scale set. The default value is false. - :paramtype enabled: bool + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.enabled = enabled + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags class ResourceSharingProfile(_serialization.Model): @@ -6188,17 +6501,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_07_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_07_01.models.ApiEntityReference] @@ -6225,6 +6589,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}, } @@ -6233,6 +6598,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"}, @@ -6280,23 +6646,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_07_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_07_01.models.RestorePointCollectionSourceProperties @@ -6313,6 +6684,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}, @@ -6323,8 +6695,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"}, @@ -6340,16 +6713,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_07_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 @@ -6359,27 +6732,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_07_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_07_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. @@ -6697,7 +7072,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. @@ -6771,10 +7146,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_07_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_07_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_07_01.models.RestorePointSourceVMDataDisk] + :vartype data_disk_list: + list[~azure.mgmt.compute.v2024_07_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 @@ -6786,30 +7162,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_07_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_07_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_07_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 @@ -6917,7 +7293,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 = { @@ -7070,23 +7446,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_07_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_07_01.models.RollingUpgradePolicy :ivar running_status: Information about the current running state of the overall upgrade. @@ -7102,6 +7483,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}, @@ -7113,8 +7495,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"}, @@ -7123,12 +7506,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 @@ -7453,7 +7836,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. @@ -8132,23 +8521,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_07_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, @@ -8160,6 +8554,7 @@ class SshPublicKeyResource(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -8167,8 +8562,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"}, } @@ -8176,17 +8572,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 @@ -8367,6 +8763,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_07_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_07_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_07_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_07_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. @@ -8763,6 +9223,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. @@ -8920,23 +9408,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_07_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 @@ -9075,6 +9568,7 @@ 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}, @@ -9089,8 +9583,9 @@ 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"}, @@ -9162,10 +9657,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 @@ -9282,7 +9777,7 @@ def __init__( # pylint: disable=too-many-locals to the VM/VMSS. :paramtype application_profile: ~azure.mgmt.compute.v2024_07_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 @@ -9484,9 +9979,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 = { @@ -9516,21 +10011,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_07_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 @@ -9549,10 +10051,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. @@ -9575,15 +10077,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"}, @@ -9605,7 +10110,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, @@ -9613,8 +10118,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, @@ -9622,10 +10127,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 @@ -9644,10 +10149,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_07_01.models.VirtualMachineExtensionInstanceView @@ -9663,7 +10168,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 @@ -9718,23 +10223,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_07_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. @@ -9754,6 +10264,7 @@ class VirtualMachineExtensionImage(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, } @@ -9761,8 +10272,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"}, @@ -9783,10 +10295,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. @@ -9801,7 +10313,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 @@ -9904,10 +10416,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. @@ -9945,8 +10457,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 @@ -9971,10 +10483,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. @@ -10166,7 +10678,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :vartype plan: ~azure.mgmt.compute.v2024_07_01.models.PurchasePlan :ivar os_disk_image: Contains the os disk image information. :vartype os_disk_image: ~azure.mgmt.compute.v2024_07_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_07_01.models.DataDiskImage] :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: @@ -10248,7 +10760,7 @@ def __init__( :paramtype plan: ~azure.mgmt.compute.v2024_07_01.models.PurchasePlan :keyword os_disk_image: Contains the os disk image information. :paramtype os_disk_image: ~azure.mgmt.compute.v2024_07_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_07_01.models.DataDiskImage] :keyword automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. @@ -10314,7 +10826,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 @@ -10332,7 +10844,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"}, @@ -10342,7 +10854,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 @@ -10350,7 +10862,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 @@ -11200,23 +11712,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_07_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_07_01.models.VirtualMachineRunCommandScriptSource :ivar parameters: The parameters used by the script. @@ -11282,6 +11799,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}, @@ -11291,8 +11809,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]"}, @@ -11323,7 +11842,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, @@ -11331,14 +11850,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_07_01.models.VirtualMachineRunCommandScriptSource :keyword parameters: The parameters used by the script. @@ -11388,7 +11907,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 @@ -11679,7 +12198,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, @@ -11687,7 +12206,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: """ @@ -11759,23 +12278,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_07_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_07_01.models.Sku :ivar plan: Specifies information about the marketplace image used to create the virtual @@ -11786,7 +12310,7 @@ class VirtualMachineScaleSet(Resource): :vartype plan: ~azure.mgmt.compute.v2024_07_01.models.Plan :ivar identity: The identity of the virtual machine scale set, if configured. :vartype identity: ~azure.mgmt.compute.v2024_07_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_07_01.models.ExtendedLocation @@ -11867,6 +12391,7 @@ class VirtualMachineScaleSet(Resource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "location": {"required": True}, "etag": {"readonly": True}, "provisioning_state": {"readonly": True}, @@ -11878,8 +12403,9 @@ 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"}, @@ -11955,10 +12481,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_07_01.models.Sku :keyword plan: Specifies information about the marketplace image used to create the virtual @@ -11969,7 +12495,7 @@ def __init__( # pylint: disable=too-many-locals :paramtype plan: ~azure.mgmt.compute.v2024_07_01.models.Plan :keyword identity: The identity of the virtual machine scale set, if configured. :paramtype identity: ~azure.mgmt.compute.v2024_07_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_07_01.models.ExtendedLocation @@ -12039,7 +12565,7 @@ 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_07_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 @@ -12204,17 +12730,22 @@ def __init__( self.delete_option = delete_option -class VirtualMachineScaleSetExtension(SubResourceReadOnly): +class VirtualMachineScaleSetExtension(ProxyResource): """Describes a Virtual Machine Scale Set Extension. 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: The name of the extension. + :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_07_01.models.SystemData :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 @@ -12233,10 +12764,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 @@ -12254,7 +12785,9 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): _validation = { "id": {"readonly": True}, + "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -12262,6 +12795,7 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "publisher": {"key": "properties.publisher", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, @@ -12282,23 +12816,20 @@ class VirtualMachineScaleSetExtension(SubResourceReadOnly): def __init__( self, *, - name: Optional[str] = None, force_update_tag: Optional[str] = None, publisher: Optional[str] = None, type_properties_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 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 @@ -12317,10 +12848,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] @@ -12334,8 +12865,6 @@ def __init__( ~azure.mgmt.compute.v2024_07_01.models.KeyVaultSecretReference """ super().__init__(**kwargs) - self.name = name - self.type = None self.force_update_tag = force_update_tag self.publisher = publisher self.type_properties_type = type_properties_type @@ -12453,10 +12982,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 @@ -12509,8 +13038,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, @@ -12535,10 +13064,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] @@ -14849,23 +15378,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_07_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. @@ -14957,6 +15491,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}, @@ -14975,8 +15510,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"}, @@ -15029,10 +15565,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 @@ -15093,7 +15629,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 @@ -15121,17 +15657,22 @@ def __init__( # pylint: disable=too-many-locals self.time_created = None -class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): +class VirtualMachineScaleSetVMExtension(ProxyResource): """Describes a VMSS VM Extension. 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: The name of the extension. + :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_07_01.models.SystemData :ivar location: The location of the extension. :vartype location: str :ivar force_update_tag: How the extension handler should be forced to update even if the @@ -15152,10 +15693,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. @@ -15178,6 +15719,7 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -15185,6 +15727,7 @@ class VirtualMachineScaleSetVMExtension(SubResourceReadOnly): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "location": {"key": "location", "type": "str"}, "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "publisher": {"key": "properties.publisher", "type": "str"}, @@ -15214,8 +15757,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, @@ -15243,10 +15786,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_07_01.models.VirtualMachineExtensionInstanceView @@ -15263,8 +15806,6 @@ def __init__( :paramtype provision_after_extensions: list[str] """ super().__init__(**kwargs) - self.name = None - self.type = None self.location = location self.force_update_tag = force_update_tag self.publisher = publisher @@ -15362,10 +15903,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. @@ -15410,8 +15951,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 @@ -15435,10 +15976,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. @@ -16072,19 +16613,31 @@ class VirtualMachineSizeListResult(_serialization.Model): :ivar value: The list of virtual machine sizes. :vartype value: list[~azure.mgmt.compute.v2024_07_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_07_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_07_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/operations/__init__.py index 5cc9a11e2341..6718c8ecb4f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/operations/_operations.py index 134f032082db..eaa30dce4c4e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2024_07_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_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 {}) @@ -290,20 +271,20 @@ 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}/vmSizes", ) # 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") @@ -311,90 +292,87 @@ def build_virtual_machine_scale_sets_get_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", 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, +def build_capacity_reservation_groups_list_by_subscription_request( # pylint: disable=name-too-long subscription_id: str, *, - hibernate: Optional[bool] = None, + 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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/deallocate", + "template_url", "/subscriptions/{subscriptionId}/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), } _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") + 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 - 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_delete_instances_request( # pylint: disable=name-too-long +def build_capacity_reservation_groups_list_by_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, - vm_scale_set_name: str, subscription_id: str, *, - force_deletion: Optional[bool] = None, + 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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/delete", + "/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 - 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") + 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_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_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 {}) @@ -405,18 +383,24 @@ def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disab # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", + "/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") @@ -424,23 +408,29 @@ def build_virtual_machine_scale_sets_get_instance_view_request( # pylint: disab return HttpRequest(method="GET", 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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", + "/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"), - "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 @@ -449,26 +439,36 @@ def build_virtual_machine_scale_sets_list_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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/virtualMachineScaleSets" - ) + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", + ) # 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" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -477,13 +477,15 @@ def build_virtual_machine_scale_sets_list_all_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", 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_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 {}) @@ -494,12 +496,16 @@ 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/{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 @@ -510,11 +516,11 @@ def build_virtual_machine_scale_sets_list_skus_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="DELETE", 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_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 {}) @@ -523,14 +529,9 @@ def build_virtual_machine_scale_sets_get_os_upgrade_history_request( # pylint: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory", - ) # 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 @@ -544,83 +545,80 @@ 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_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-07-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}/poweroff", + "/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 # 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="GET", 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_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-07-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}/restart", + "/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_start_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 {}) @@ -632,13 +630,15 @@ def build_virtual_machine_scale_sets_start_request( # pylint: disable=name-too- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", + "/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 @@ -650,27 +650,30 @@ def build_virtual_machine_scale_sets_start_request( # pylint: disable=name-too- _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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/reapply", + "/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 @@ -679,30 +682,33 @@ def build_virtual_machine_scale_sets_reapply_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="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_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_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-07-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/{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 @@ -711,32 +717,22 @@ 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="DELETE", 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 -) -> 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-07-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", - ) # 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 @@ -745,32 +741,30 @@ def build_virtual_machine_scale_sets_perform_maintenance_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="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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/manualupgrade", + "/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 @@ -779,49 +773,48 @@ def build_virtual_machine_scale_sets_update_instances_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="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_reimage_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-07-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}/reimage", + "/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_reimage_all_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 {}) @@ -833,12 +826,14 @@ def build_virtual_machine_scale_sets_reimage_all_request( # pylint: disable=nam # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall", + "/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 @@ -851,11 +846,11 @@ def build_virtual_machine_scale_sets_reimage_all_request( # pylint: disable=nam _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_approve_rolling_upgrade_request( # pylint: disable=name-too-long - resource_group_name: str, vm_scale_set_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 {}) @@ -867,12 +862,14 @@ def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/approveRollingUpgrade", + "/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 @@ -885,18 +882,11 @@ def build_virtual_machine_scale_sets_approve_rolling_upgrade_request( # pylint: _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_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_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 {}) @@ -907,49 +897,45 @@ 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/{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") - _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="DELETE", 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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"), - "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 @@ -958,32 +944,30 @@ def build_virtual_machine_scale_sets_convert_to_single_placement_group_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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/setOrchestrationServiceState", + "/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"), - "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 @@ -992,33 +976,31 @@ def build_virtual_machine_scale_sets_set_orchestration_service_state_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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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"), - "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"), + "offer": _SERIALIZER.url("offer", offer, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1027,50 +1009,70 @@ def build_virtual_machine_scale_set_extensions_create_or_update_request( # pyli _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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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"), - "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"), + "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 - 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_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_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 {}) @@ -1081,13 +1083,16 @@ 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/{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"), - "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_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 @@ -1098,17 +1103,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_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 {}) @@ -1119,20 +1118,17 @@ 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}/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"), - "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 # 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 +1137,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_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 {}) @@ -1152,13 +1148,11 @@ 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", + "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 @@ -1172,8 +1166,8 @@ 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_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 {}) @@ -1184,12 +1178,12 @@ 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}/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"), - "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 @@ -1200,11 +1194,11 @@ def build_virtual_machine_scale_set_rolling_upgrades_cancel_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_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_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 {}) @@ -1215,12 +1209,13 @@ 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}/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), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offer": _SERIALIZER.url("offer", offer, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1231,11 +1226,20 @@ 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_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 {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1246,27 +1250,35 @@ 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}/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), + "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_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_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 {}) @@ -1277,12 +1289,15 @@ 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", + "/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"), - "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 @@ -1296,13 +1311,8 @@ 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_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 {}) @@ -1314,14 +1324,11 @@ def build_virtual_machine_scale_set_vm_extensions_create_or_update_request( # p # 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}/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"), - "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), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1334,16 +1341,11 @@ def build_virtual_machine_scale_set_vm_extensions_create_or_update_request( # p _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_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_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 {}) @@ -1355,14 +1357,11 @@ def build_virtual_machine_scale_set_vm_extensions_update_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}/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"), - "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), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1375,16 +1374,11 @@ def build_virtual_machine_scale_set_vm_extensions_update_request( # pylint: dis _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_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 +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 {}) @@ -1395,14 +1389,12 @@ 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/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"), - "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 @@ -1413,17 +1405,18 @@ def build_virtual_machine_scale_set_vm_extensions_delete_request( # pylint: dis # 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, +def build_virtual_machine_extension_images_list_versions_request( # pylint: disable=name-too-long + location: str, + publisher_name: str, + type: str, subscription_id: str, *, - expand: Optional[str] = None, + filter: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1435,22 +1428,25 @@ 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/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"), - "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"), + "type": _SERIALIZER.url("type", type, "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 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") @@ -1458,14 +1454,8 @@ 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, - subscription_id: str, - *, - expand: 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 {}) @@ -1476,20 +1466,19 @@ 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/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 # 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 @@ -1498,26 +1487,22 @@ 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_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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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}/reimage", + "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 @@ -1526,32 +1511,29 @@ def build_virtual_machine_scale_set_vms_reimage_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="GET", 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_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-07-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}/reimageall", + "/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 @@ -1562,11 +1544,11 @@ def build_virtual_machine_scale_set_vms_reimage_all_request( # pylint: disable= # 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_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_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 {}) @@ -1577,28 +1559,37 @@ 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}/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") - 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_run_commands_get_by_virtual_machine_request( # pylint: disable=name-too-long + resource_group_name: str, + vm_name: 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 {}) @@ -1609,35 +1600,32 @@ 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}/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 _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="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_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 {}) @@ -1649,13 +1637,15 @@ def build_virtual_machine_scale_set_vms_update_request( # pylint: disable=name- # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + "/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 @@ -1664,10 +1654,6 @@ 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") @@ -1675,54 +1661,45 @@ def build_virtual_machine_scale_set_vms_update_request( # pylint: disable=name- return HttpRequest(method="PUT", 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_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-07-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}/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 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 + 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_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_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 {}) @@ -1733,31 +1710,29 @@ def build_virtual_machine_scale_set_vms_get_request( # pylint: disable=name-too # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}", + "/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 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="DELETE", 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 -) -> 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 {}) @@ -1766,14 +1741,11 @@ 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", + "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 @@ -1787,15 +1759,8 @@ 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 - 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 +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 {}) @@ -1806,25 +1771,16 @@ 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}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets", ) # 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"), + "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 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") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1833,14 +1789,8 @@ 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_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 {}) @@ -1850,31 +1800,25 @@ def build_virtual_machine_scale_set_vms_power_off_request( # pylint: disable=na # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", - ) # 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 # 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_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_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 {}) @@ -1885,13 +1829,13 @@ def build_virtual_machine_scale_set_vms_restart_request( # pylint: disable=name # 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/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 @@ -1902,11 +1846,16 @@ def build_virtual_machine_scale_set_vms_restart_request( # pylint: disable=name # 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_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_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 {}) @@ -1917,45 +1866,56 @@ 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/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 _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_redeploy_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-07-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}/redeploy", + "/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 @@ -1964,55 +1924,70 @@ def build_virtual_machine_scale_set_vms_redeploy_request( # pylint: disable=nam _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_scale_set_vms_retrieve_boot_diagnostics_data_request( # pylint: disable=name-too-long +def build_virtual_machine_scale_sets_update_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, + 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-07-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}/retrieveBootDiagnosticsData", + "/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 - 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="PATCH", 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_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 {}) @@ -2023,45 +1998,50 @@ 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", + "/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 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_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_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-07-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}/simulateEviction", + "/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"), + "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 @@ -2070,13 +2050,15 @@ def build_virtual_machine_scale_set_vms_simulate_eviction_request( # pylint: di _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_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_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 {}) @@ -2088,13 +2070,14 @@ def build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( # pyl # 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}/convertToSinglePlacementGroup", ) # 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 @@ -2110,32 +2093,40 @@ def build_virtual_machine_scale_set_vms_attach_detach_data_disks_request( # pyl return HttpRequest(method="POST", 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_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-07-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}/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 + ), "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 hibernate is not None: + _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") # Construct headers if content_type is not None: @@ -2145,8 +2136,13 @@ def build_virtual_machine_scale_set_vms_run_command_request( # pylint: disable= return HttpRequest(method="POST", 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_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 {}) @@ -2158,65 +2154,78 @@ 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}/delete", ) # 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", 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_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-07-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}/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"), - "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") + _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", 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_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 {}) @@ -2227,13 +2236,14 @@ def build_virtual_machine_extensions_delete_request( # pylint: disable=name-too # 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}/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"), - "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 @@ -2244,51 +2254,47 @@ def build_virtual_machine_extensions_delete_request( # pylint: disable=name-too # 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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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"), - "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_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 {}) @@ -2299,19 +2305,19 @@ def build_virtual_machine_extensions_list_request( # pylint: disable=name-too-l # 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}/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 expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -2320,23 +2326,27 @@ def build_virtual_machine_extensions_list_request( # pylint: disable=name-too-l return HttpRequest(method="GET", 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_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-07-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}/performMaintenance", ) # 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 @@ -2345,13 +2355,20 @@ def build_virtual_machines_list_by_location_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="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_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 {}) @@ -2363,18 +2380,22 @@ def build_virtual_machines_capture_request( # 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}/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: @@ -2384,31 +2405,26 @@ def build_virtual_machines_capture_request( 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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 @@ -2417,25 +2433,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="POST", 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_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 {}) @@ -2447,12 +2451,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}/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 @@ -2461,111 +2467,106 @@ 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_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-07-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}/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 # 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 + 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_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_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-07-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}/reimageall", ) # 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_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-07-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}/restart", ) # 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 @@ -2574,29 +2575,34 @@ def build_virtual_machines_instance_view_request( # pylint: disable=name-too-lo _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_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_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-07-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}/convertToManagedDisks", + "/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 @@ -2605,13 +2611,15 @@ def build_virtual_machines_convert_to_managed_disks_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_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_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 {}) @@ -2622,45 +2630,48 @@ def build_virtual_machines_deallocate_request( # pylint: disable=name-too-long # 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}/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 hibernate is not None: - _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "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_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_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-07-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}/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 @@ -2669,18 +2680,15 @@ 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_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 {}) @@ -2691,20 +2699,16 @@ def build_virtual_machines_list_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", + "/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"), - "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 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 @@ -2730,7 +2734,7 @@ def build_virtual_machines_list_all_request( # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") 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 @@ -2750,8 +2754,13 @@ def build_virtual_machines_list_all_request( return HttpRequest(method="GET", 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 +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 {}) @@ -2762,18 +2771,23 @@ def build_virtual_machines_list_available_sizes_request( # pylint: disable=name # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", + "/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") @@ -2781,8 +2795,13 @@ def build_virtual_machines_list_available_sizes_request( # pylint: disable=name return HttpRequest(method="GET", 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_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 {}) @@ -2793,45 +2812,56 @@ 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/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 skip_shutdown is not None: - _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool") _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="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_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 ) -> 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-07-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/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 @@ -2840,29 +2870,44 @@ def build_virtual_machines_reapply_request( _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) + 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) -def build_virtual_machines_restart_request( - 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-07-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}/restart", + "/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 @@ -2871,13 +2916,24 @@ def build_virtual_machines_restart_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", 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_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 {}) @@ -2888,26 +2944,30 @@ def build_virtual_machines_start_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", + "/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_redeploy_request( +def build_virtual_machines_assess_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 {}) @@ -2919,12 +2979,14 @@ 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/{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 @@ -2938,7 +3000,7 @@ def build_virtual_machines_redeploy_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_reimage_request( +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 {}) @@ -2951,12 +3013,14 @@ def build_virtual_machines_reimage_request( # 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}/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 @@ -2972,47 +3036,43 @@ def build_virtual_machines_reimage_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -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 +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 {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/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 # 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 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_perform_maintenance_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 {}) @@ -3024,12 +3084,14 @@ def build_virtual_machines_perform_maintenance_request( # pylint: disable=name- # 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}/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 @@ -3043,8 +3105,8 @@ def build_virtual_machines_perform_maintenance_request( # pylint: disable=name- return HttpRequest(method="POST", 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_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 {}) @@ -3055,18 +3117,22 @@ 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}/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 _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -3074,7 +3140,7 @@ def build_virtual_machines_simulate_eviction_request( # pylint: disable=name-to return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_assess_patches_request( # pylint: disable=name-too-long +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 {}) @@ -3086,12 +3152,14 @@ def build_virtual_machines_assess_patches_request( # pylint: disable=name-too-l # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", ) # 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 @@ -3121,9 +3189,11 @@ def build_virtual_machines_install_patches_request( # pylint: disable=name-too- "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches", ) # 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,25 +3209,26 @@ 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/attachDetachDataDisks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView", ) # 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 @@ -3166,32 +3237,31 @@ def build_virtual_machines_attach_detach_data_disks_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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_virtual_machines_run_command_request( # pylint: disable=name-too-long +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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}/performMaintenance", ) # 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,15 +3270,13 @@ def build_virtual_machines_run_command_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_machine_images_get_request( - location: str, publisher_name: str, offer: str, skus: str, version: 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 {}) @@ -3219,39 +3287,31 @@ 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}/powerOff", ) # 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 # 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_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_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 {}) @@ -3262,35 +3322,29 @@ def build_virtual_machine_images_list_request( # pylint: disable=name-too-long # 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 - 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 _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_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 {}) @@ -3301,12 +3355,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}/redeploy", ) # 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 @@ -3317,25 +3373,30 @@ def build_virtual_machine_images_list_offers_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_virtual_machine_images_list_publishers_request( # pylint: disable=name-too-long - location: str, subscription_id: str, **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-07-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}/reimage", ) # 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 @@ -3344,13 +3405,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_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 {}) @@ -3361,13 +3424,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}/restart", ) # 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 @@ -3378,11 +3442,16 @@ 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_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 {}) @@ -3393,54 +3462,52 @@ 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}/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_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_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-07-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/{version}", + "/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"), - "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 @@ -3449,23 +3516,15 @@ def build_virtual_machine_images_edge_zone_get_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_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_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 {}) @@ -3476,36 +3535,29 @@ def build_virtual_machine_images_edge_zone_list_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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction", ) # 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 _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_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 {}) @@ -3516,13 +3568,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}/start", ) # 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 @@ -3533,11 +3586,11 @@ 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_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 {}) @@ -3548,12 +3601,14 @@ 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}/vmSizes", ) # 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 @@ -3567,9 +3622,7 @@ def build_virtual_machine_images_edge_zone_list_publishers_request( # pylint: d return HttpRequest(method="GET", 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 -) -> 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 {}) @@ -3578,15 +3631,11 @@ def build_virtual_machine_images_edge_zone_list_skus_request( # pylint: disable # Construct URL _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes" ) # 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), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3600,8 +3649,8 @@ def build_virtual_machine_images_edge_zone_list_skus_request( # pylint: disable return HttpRequest(method="GET", 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_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 {}) @@ -3611,15 +3660,10 @@ 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}", - ) # pylint: disable=line-too-long + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups" + ) 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), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3633,8 +3677,8 @@ def build_virtual_machine_extension_images_get_request( # pylint: disable=name- return HttpRequest(method="GET", 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_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 {}) @@ -3645,12 +3689,13 @@ 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/proximityPlacementGroups", ) # 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 + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -3664,15 +3709,12 @@ def build_virtual_machine_extension_images_list_types_request( # pylint: disabl return HttpRequest(method="GET", 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, +def build_proximity_placement_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, + proximity_placement_group_name: str, subscription_id: str, *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3684,25 +3726,26 @@ 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/proximityPlacementGroups/{proximityPlacementGroupName}", ) # 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 + ), + "proximityPlacementGroupName": _SERIALIZER.url( + "proximity_placement_group_name", proximity_placement_group_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") + 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") @@ -3710,8 +3753,8 @@ 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 +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 {}) @@ -3723,12 +3766,16 @@ def build_availability_sets_create_or_update_request( # pylint: disable=name-to # 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 @@ -3744,8 +3791,8 @@ def build_availability_sets_create_or_update_request( # pylint: disable=name-to return HttpRequest(method="PUT", 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_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 {}) @@ -3757,12 +3804,16 @@ def build_availability_sets_update_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 @@ -3778,8 +3829,8 @@ def build_availability_sets_update_request( return HttpRequest(method="PATCH", 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_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 {}) @@ -3790,12 +3841,16 @@ 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/{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 @@ -3809,8 +3864,8 @@ def build_availability_sets_delete_request( return HttpRequest(method="DELETE", 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 +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 {}) @@ -3820,13 +3875,10 @@ def build_availability_sets_get_request( # 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/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 @@ -3840,8 +3892,8 @@ 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_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 {}) @@ -3850,17 +3902,21 @@ def build_availability_sets_list_by_subscription_request( # pylint: disable=nam accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections", + ) # 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 # 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") @@ -3868,7 +3924,14 @@ def build_availability_sets_list_by_subscription_request( # pylint: disable=nam 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: +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 {}) @@ -3878,17 +3941,24 @@ def build_availability_sets_list_request(resource_group_name: str, subscription_ # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", + "/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"), - "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 _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -3896,24 +3966,29 @@ def build_availability_sets_list_request(resource_group_name: str, subscription_ return HttpRequest(method="GET", 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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/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 @@ -3922,13 +3997,15 @@ 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="PUT", 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_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 {}) @@ -3940,14 +4017,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 @@ -3960,30 +4039,31 @@ def build_proximity_placement_groups_create_or_update_request( # pylint: disabl _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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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/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 @@ -3992,15 +4072,13 @@ def build_proximity_placement_groups_update_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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", 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_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 {}) @@ -4009,16 +4087,9 @@ def build_proximity_placement_groups_delete_request( # pylint: disable=name-too 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 @@ -4029,16 +4100,11 @@ def build_proximity_placement_groups_delete_request( # pylint: disable=name-too # 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_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_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 {}) @@ -4049,23 +4115,18 @@ def build_proximity_placement_groups_get_request( # pylint: disable=name-too-lo # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys", ) # 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 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _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 @@ -4074,8 +4135,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_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 {}) @@ -4085,10 +4146,15 @@ 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/{sshPublicKeyName}", + ) # 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 + ), + "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -4102,23 +4168,27 @@ 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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/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 @@ -4127,13 +4197,15 @@ def build_proximity_placement_groups_list_by_resource_group_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="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", 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_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 {}) @@ -4145,12 +4217,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 @@ -4163,28 +4237,29 @@ def build_dedicated_host_groups_create_or_update_request( # pylint: disable=nam _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_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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}", ) # 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 @@ -4193,31 +4268,32 @@ def build_dedicated_host_groups_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="DELETE", 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_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-07-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 @@ -4226,18 +4302,15 @@ def build_dedicated_host_groups_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="POST", 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_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 {}) @@ -4248,19 +4321,21 @@ def build_dedicated_host_groups_get_request( # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", + "/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"), - "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 + ), + "capacityReservationGroupName": _SERIALIZER.url( + "capacity_reservation_group_name", capacity_reservation_group_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 @@ -4269,8 +4344,14 @@ def build_dedicated_host_groups_get_request( return HttpRequest(method="GET", 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_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 {}) @@ -4281,17 +4362,25 @@ 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/{capacityReservationName}", ) # 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" + ), + "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") @@ -4299,19 +4388,34 @@ 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_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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/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 @@ -4320,13 +4424,19 @@ def build_dedicated_host_groups_list_by_subscription_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="PUT", 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_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 {}) @@ -4338,13 +4448,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 @@ -4357,29 +4471,36 @@ def build_dedicated_hosts_create_or_update_request( # pylint: disable=name-too- _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_dedicated_hosts_update_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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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}", + "/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 @@ -4388,15 +4509,13 @@ def build_dedicated_hosts_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_dedicated_hosts_delete_request( - resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any +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 {}) @@ -4407,13 +4526,14 @@ 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/hostGroups/{hostGroupName}/hosts", ) # 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 @@ -4424,7 +4544,7 @@ def build_dedicated_hosts_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_dedicated_hosts_get_request( @@ -4448,18 +4568,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") @@ -4467,24 +4589,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-07-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 @@ -4493,30 +4619,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-07-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 @@ -4525,12 +4656,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 {}) @@ -4542,13 +4675,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 @@ -4559,7 +4694,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 @@ -4577,10 +4712,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 @@ -4594,8 +4731,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 {}) @@ -4604,9 +4741,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 @@ -4617,11 +4762,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 {}) @@ -4632,11 +4777,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 @@ -4647,62 +4796,81 @@ 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-07-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 -) -> 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-07-01")) +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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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 @@ -4715,11 +4883,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 {}) @@ -4730,12 +4902,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 @@ -4749,8 +4926,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 {}) @@ -4761,12 +4938,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 @@ -4777,28 +4956,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-07-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 @@ -4807,32 +4987,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-07-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 @@ -4841,32 +5020,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-07-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 @@ -4875,15 +5053,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 {}) @@ -4894,12 +5070,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 @@ -4910,11 +5088,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 {}) @@ -4925,20 +5109,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") @@ -4946,23 +5133,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-07-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 @@ -4971,22 +5163,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-07-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 @@ -4995,32 +5200,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-07-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 @@ -5029,33 +5236,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-07-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}$" ), } @@ -5063,17 +5276,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 {}) @@ -5084,69 +5307,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-07-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 {}) @@ -5157,26 +5397,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 {}) @@ -5186,10 +5432,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 @@ -5200,15 +5452,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 {}) @@ -5220,15 +5468,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 @@ -5241,15 +5489,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 {}) @@ -5260,15 +5504,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 @@ -5279,17 +5523,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 {}) @@ -5300,22 +5538,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 @@ -5324,27 +5560,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-07-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 @@ -5353,51 +5589,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-07-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 {}) @@ -5408,14 +5648,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 @@ -5426,55 +5667,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-07-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 {}) @@ -5485,32 +5719,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 {}) @@ -5520,74 +5752,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-07-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 {}) @@ -5599,15 +5832,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 @@ -5620,15 +5853,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 {}) @@ -5639,15 +5868,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 @@ -5658,17 +5887,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 {}) @@ -5679,32 +5902,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 {}) @@ -5715,20 +5942,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") @@ -5736,125 +5966,43 @@ 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 -) -> 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-07-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", - ) # 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 - 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_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_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-07-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/getThrottledRequests", - ) # 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 - 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_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-07-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-07-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}", + "/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\._]+$"), - "commandId": _SERIALIZER.url("command_id", command_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 + ), + "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 _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -5862,26 +6010,34 @@ def build_virtual_machine_run_commands_get_request( # pylint: disable=name-too- 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 +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 {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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 @@ -5897,26 +6053,34 @@ def build_virtual_machine_run_commands_create_or_update_request( # pylint: disa 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-07-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 @@ -5932,25 +6096,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-07-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 @@ -5964,10 +6136,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, @@ -5977,26 +6149,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-07-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") @@ -6004,32 +6178,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-07-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") @@ -6050,7 +6235,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-07-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( @@ -6058,11 +6243,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 @@ -6091,7 +6278,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-07-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( @@ -6099,11 +6286,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 @@ -6131,7 +6320,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-07-01")) - accept = _headers.pop("Accept", "application/json, text/json") + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( @@ -6139,11 +6328,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 @@ -6157,41 +6348,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-07-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") @@ -6199,10 +6383,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, @@ -6212,26 +6396,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-07-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") @@ -6239,110 +6425,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. +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 {}) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`operations` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - models = _models + # 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"), + } - 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") + _url: str = _url.format(**path_format_arguments) # type: ignore - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ComputeOperationValue"]: - """Gets a list of compute operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :return: An iterator like instance of either ComputeOperationValue or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.ComputeOperationValue] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) 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") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.ComputeOperationListResult] = kwargs.pop("cls", None) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - 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: +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 {}) - _request = build_operations_list_request( - 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", "2024-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - 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 + # 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"), + } - 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) + _url: str = _url.format(**path_format_arguments) # type: ignore - def get_next(next_link=None): - _request = prepare_request(next_link) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_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") - 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 HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - return pipeline_response - return ItemPaged(get_next, extract_data) +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-07-01")) + accept = _headers.pop("Accept", "application/json") -class UsageOperations: + # 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_07_01.ComputeManagementClient`'s - :attr:`usage` attribute. + :attr:`operations` attribute. """ models = _models @@ -6356,21 +6554,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_07_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_07_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-07-01")) - cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6383,9 +6578,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, @@ -6410,7 +6603,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 @@ -6427,21 +6620,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_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_sizes` attribute. + :attr:`availability_sets` attribute. """ models = _models @@ -6455,21 +6649,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_07_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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6482,9 +6678,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, @@ -6509,11 +6705,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) @@ -6532,45 +6728,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_07_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_07_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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6583,8 +6756,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, @@ -6610,7 +6783,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 @@ -6633,71 +6806,55 @@ 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]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, + @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_07_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 {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -6705,174 +6862,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_07_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_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.AvailabilitySet or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -6886,7 +6950,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -6894,14 +6958,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, @@ -6911,8 +6973,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 ) @@ -6920,14 +6981,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 @@ -6935,168 +6992,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_07_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_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.AvailabilitySetUpdate or IO[bytes] + :return: AvailabilitySet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -7105,40 +7075,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-07-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 @@ -7146,84 +7122,18 @@ 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. - - :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 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 {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 - - 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, - *, - expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, - **kwargs: Any - ) -> _models.VirtualMachineScaleSet: - """Display information about a virtual machine 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 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_07_01.models.ExpandTypesForGetVMScaleSets - :return: VirtualMachineScaleSet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 = { @@ -7238,13 +7148,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-07-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_delete_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, @@ -7258,26 +7167,35 @@ def get( 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) - deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # 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. + + :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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - 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, 404: ResourceNotFoundError, @@ -7286,213 +7204,302 @@ def _deallocate_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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + _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) - 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 + # 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_sets_deallocate_request( - resource_group_name=resource_group_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, - ) - _request.url = self._client.format_url(_request.url) + 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) - _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) - 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 - @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. +class CapacityReservationGroupsOperations: + """ + .. 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_07_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: - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. + """ - @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. + 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 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: - """ + 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_deallocate( + def list_by_subscription( 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, + expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, + resource_ids_only: Optional[Union[str, _models.ResourceIdOptionsForGetCapacityReservationGroups]] = 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. + ) -> 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. - :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_07_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] + :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_07_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_07_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_07_01.models.CapacityReservationGroup] :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-07-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._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 + 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_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) + + 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 ) - 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 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, + *, + 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. 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_07_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_07_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-07-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: - 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, **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 _delete_instances_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: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + capacity_reservation_group_name: str, *, - force_deletion: Optional[bool] = None, + expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, **kwargs: Any - ) -> Iterator[bytes]: + ) -> _models.CapacityReservationGroup: + """The operation that retrieves information about a capacity reservation group. + + :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 + :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_07_01.models.CapacityReservationGroupInstanceViewTypes + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7501,52 +7508,35 @@ def _delete_instances_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-07-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: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_delete_instances_request( + _request = build_capacity_reservation_groups_get_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, - force_deletion=force_deletion, + 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("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7554,151 +7544,85 @@ def _delete_instances_initial( return deserialized # type: ignore @overload - def begin_delete_instances( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + capacity_reservation_group_name: str, + parameters: _models.CapacityReservationGroup, *, - force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Deletes virtual machines in a VM scale set. + ) -> _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 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_07_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 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_07_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: 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_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_delete_instances( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], + capacity_reservation_group_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. + ) -> _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 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: 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 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: 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_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_delete_instances( + def create_or_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], - *, - force_deletion: Optional[bool] = None, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroup, 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_07_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-07-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. + ) -> _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. + :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_07_01.models.VirtualMachineScaleSetInstanceView + :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_07_01.models.CapacityReservationGroup or IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7709,17 +7633,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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapacityReservationGroup] = 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, "CapacityReservationGroup") + + _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, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -7732,35 +7668,99 @@ def get_instance_view( 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("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) + deserialized = self._deserialize("CapacityReservationGroup", 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.VirtualMachineScaleSet"]: - """Gets a list of all VM scale sets under a resource group. + @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. - :param resource_group_name: The name of the 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_07_01.models.VirtualMachineScaleSet] + :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_07_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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) + @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. + + :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 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_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], + **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. 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 Update capacity reservation Group operation. Is + either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroupUpdate or + IO[bytes] + :return: CapacityReservationGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7769,77 +7769,70 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Vir } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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 + 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") - 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) + _request = build_capacity_reservation_groups_update_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, + 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) + _stream = False + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @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 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. - :return: An iterator like instance of either VirtualMachineScaleSet or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] + :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 :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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7848,80 +7841,71 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: } 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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[None] = 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_delete_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) - 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) + _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, 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) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - 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_07_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") @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_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 - :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetSku] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7934,9 +7918,7 @@ def list_skus( 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, + _request = build_dedicated_host_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -7962,7 +7944,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -7986,26 +7968,22 @@ 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 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 iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.UpgradeOperationHistoricalStatusInfo] + :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8018,9 +7996,8 @@ def get_os_upgrade_history( def prepare_request(next_link=None): if not next_link: - _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( + _request = build_dedicated_host_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, api_version=api_version, headers=_headers, @@ -8046,7 +8023,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) + deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -8069,15 +8046,31 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _power_off_initial( + @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, *, - skip_shutdown: bool = False, + 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" and "userData". + Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.DedicatedHostGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8086,55 +8079,35 @@ def _power_off_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-07-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_power_off_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, - skip_shutdown=skip_shutdown, + 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 @@ -8142,158 +8115,87 @@ def _power_off_initial( return deserialized # type: ignore @overload - def begin_power_off( + 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, *, - 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.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_07_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 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_07_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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_power_off( + 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], *, - 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.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] - :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 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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_power_off( + 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, - *, - skip_shutdown: bool = False, + host_group_name: str, + parameters: Union[_models.DedicatedHostGroup, 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.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_07_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 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_07_01.models.DedicatedHostGroup or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -8307,22 +8209,19 @@ def _restart_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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: - 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_restart_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, @@ -8333,23 +8232,18 @@ 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, 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 @@ -8357,132 +8251,81 @@ def _restart_initial( return deserialized # type: ignore @overload - def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_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_07_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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_restart( + 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]: - """Restarts one or more virtual machines in a VM scale set. + ) -> _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_07_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_07_01.models.DedicatedHostGroupUpdate or IO[bytes] + :return: DedicatedHostGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -8496,22 +8339,19 @@ def _start_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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: - 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, "DedicatedHostGroupUpdate") - _request = build_virtual_machine_scale_sets_start_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, @@ -8522,150 +8362,39 @@ def _start_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_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. - - :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_07_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_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. - - :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_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 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. + :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_07_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 + :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-07-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 - - def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8678,11 +8407,11 @@ def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **k _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_reapply_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, headers=_headers, @@ -8690,95 +8419,212 @@ def _reapply_initial(self, resource_group_name: str, vm_scale_set_name: str, **k ) _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) - response_headers = {} - if response.status_code == 202: - 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_07_01.ComputeManagementClient`'s + :attr:`images` attribute. + """ - @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. + 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 - :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 {}) + 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.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. + + :return: An iterator like instance of either Image or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-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.ImageListResult] = 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_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: - 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) + 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) + + @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_07_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-07-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 ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - def _redeploy_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]: + 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_07_01.models.Image + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8787,189 +8633,43 @@ 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-07-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.Image] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_sets_redeploy_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, + 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("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # 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[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_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_07_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. 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_redeploy( - 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]: - """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_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_07_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-07-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) - - 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 _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 + 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, @@ -8989,17 +8689,14 @@ def _perform_maintenance_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_perform_maintenance_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, @@ -9018,7 +8715,7 @@ def _perform_maintenance_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): @@ -9026,97 +8723,88 @@ 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 == 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_perform_maintenance( + 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]: - """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. + ) -> 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_07_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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_perform_maintenance( + 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]: - """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. + ) -> 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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_perform_maintenance( - 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]: - """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. + 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_07_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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9124,15 +8812,15 @@ def begin_perform_maintenance( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._perform_maintenance_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, @@ -9143,30 +8831,36 @@ def begin_perform_maintenance( 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 _update_instances_initial( + def _update_initial( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -9187,14 +8881,14 @@ def _update_instances_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: - _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") + _json = self._serialize.body(parameters, "ImageUpdate") - _request = build_virtual_machine_scale_sets_update_instances_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, @@ -9213,7 +8907,7 @@ def _update_instances_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): @@ -9221,88 +8915,92 @@ def _update_instances_initial( 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) - + 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_instances( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, + image_name: str, + parameters: _models.ImageUpdate, *, 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. + ) -> LROPoller[_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 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_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs + :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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_update_instances( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: IO[bytes], + image_name: str, + parameters: 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. + ) -> LROPoller[_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 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: IO[bytes] + :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 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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_update_instances( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], + image_name: str, + parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. + ) -> 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 VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. - :type vm_instance_i_ds: - ~azure.mgmt.compute.v2024_07_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] + :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_07_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_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -9310,15 +9008,15 @@ def begin_update_instances( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._update_instances_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, @@ -9329,32 +9027,32 @@ def begin_update_instances( 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 _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]: + def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -9363,32 +9061,17 @@ 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-07-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 - - _request = build_virtual_machine_scale_sets_reimage_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, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -9402,7 +9085,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): @@ -9410,110 +9093,44 @@ 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, - 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. - - :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_07_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: - """ - - @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. 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. + 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. + :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_07_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] + :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 = 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-07-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, - vm_scale_set_reimage_input=vm_scale_set_reimage_input, + image_name=image_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -9527,7 +9144,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: @@ -9541,205 +9160,101 @@ 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, - 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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - 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 + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. + """ - _request = build_virtual_machine_scale_sets_reimage_all_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, + 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_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_07_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-07-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + + _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 = 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_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. - :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_07_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_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. - - :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_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 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. 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_07_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 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_07_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-07-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_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 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 _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, 404: ResourceNotFoundError, @@ -9748,215 +9263,143 @@ def _approve_rolling_upgrade_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-07-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[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", 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, + _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 [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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @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. + @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 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_07_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] + :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_07_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_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. + _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. 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: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) + cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) - @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. + _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) - :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_07_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 {}) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._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 - ) - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - 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 + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long + def list( self, - resource_group_name: str, - vm_scale_set_name: str, + location: str, + edge_zone: str, + publisher_name: str, + offer: str, + skus: str, *, - platform_update_domain: int, - zone: Optional[str] = None, - placement_group_id: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, **kwargs: Any - ) -> _models.RecoveryWalkResponse: - """Manual platform update domain walk to update virtual machines in a service fabric virtual - machine scale set. + ) -> List[_models.VirtualMachineImageResource]: + """Gets a list of all virtual machine image versions for the specified location, edge zone, + 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 - :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_07_01.models.RecoveryWalkResponse + :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_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9971,15 +9414,18 @@ 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-07-01")) - cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineImageResource]] = 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, + _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, - platform_update_domain=platform_update_domain, - zone=zone, - placement_group_id=placement_group_id, + expand=expand, + top=top, + orderby=orderby, api_version=api_version, headers=_headers, params=_params, @@ -9995,92 +9441,115 @@ def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disabl 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) - deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) + deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # 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. - - :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: - ~azure.mgmt.compute.v2024_07_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: - """ + @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. - @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. 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 + :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_07_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-07-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_07_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 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_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 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_07_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: VmImagesInEdgeZoneListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.VmImagesInEdgeZoneListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10091,29 +9560,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-07-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[_models.VmImagesInEdgeZoneListResult] = 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_list_by_edge_zone_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, ) @@ -10128,18 +9585,26 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st 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) + + deserialized = self._deserialize("VmImagesInEdgeZoneListResult", 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_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_07_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10148,206 +9613,191 @@ 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-07-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_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, 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_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 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_07_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 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_07_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. + _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 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: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 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. + 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 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_07_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] + :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_07_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-07-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_list_skus_request( + location=location, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_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, + 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, 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_07_01.models.VirtualMachineImageResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10356,208 +9806,134 @@ 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-07-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_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, - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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, 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 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_07_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_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @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_07_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 + :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_07_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 {}) - @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. - - :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_07_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_07_01.models.VirtualMachineScaleSetExtension] - :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-07-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.VirtualMachineImage] = 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_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) - 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 + 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 LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`log_analytics` 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 _export_request_rate_by_interval_initial( + self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10577,15 +9953,13 @@ 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, "VirtualMachineScaleSetExtensionUpdate") + _json = self._serialize.body(parameters, "RequestRateByIntervalInput") - _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_log_analytics_export_request_rate_by_interval_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -10604,115 +9978,95 @@ def _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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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_update( + def begin_export_request_rate_by_interval( self, - resource_group_name: str, - vm_scale_set_name: str, - vmss_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, + location: str, + parameters: _models.RequestRateByIntervalInput, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: - """The operation to update an extension. + ) -> 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 where the extension should be updated. + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. 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_07_01.models.VirtualMachineScaleSetExtensionUpdate + :type parameters: ~azure.mgmt.compute.v2024_07_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 VirtualMachineScaleSetExtension or the - result of cls(response) + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.LogAnalyticsOperationResult] :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. + 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 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. + :param location: The name of Azure region. Required. + :type location: str + :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. 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] + :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 VirtualMachineScaleSetExtension or the - result of cls(response) + :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result + of cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.LogAnalyticsOperationResult] :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 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 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_07_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the - result of cls(response) + :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_07_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_07_01.models.VirtualMachineScaleSetExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -10720,16 +10074,14 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", 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._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, + 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, @@ -10741,30 +10093,32 @@ def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtension", 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: 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[_models.VirtualMachineScaleSetExtension].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[_models.VirtualMachineScaleSetExtension]( + return LROPoller[_models.LogAnalyticsOperationResult]( 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 + def _export_throttled_requests_initial( + self, location: str, body: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10774,18 +10128,28 @@ 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-07-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_extensions_delete_request( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "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, ) @@ -10799,52 +10163,109 @@ 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): pass 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) + + 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, + body: _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 body: The request body. Required. + :type body: ~azure.mgmt.compute.v2024_07_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_07_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_throttled_requests( + self, location: str, body: 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 body: The request body. Required. + :type body: 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_07_01.models.LogAnalyticsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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. + def begin_export_throttled_requests( + self, location: str, body: 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 where the extension should be deleted. + :param location: The name of Azure region. Required. + :type location: str + :param body: The request body. Is either a ThrottledRequestsInput type or a IO[bytes] type. 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] + :type body: ~azure.mgmt.compute.v2024_07_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_07_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-07-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._delete_initial( - resource_group_name=resource_group_name, - vm_scale_set_name=vm_scale_set_name, - vmss_extension_name=vmss_extension_name, + raw_result = self._export_throttled_requests_initial( + location=location, + body=body, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -10853,47 +10274,64 @@ 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("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 + ) + + +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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 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_types( + self, location: str, publisher_name: str, **kwargs: Any + ) -> List[_models.VirtualMachineExtensionImage]: + """Gets a list of virtual machine extension image types. - :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_07_01.models.VirtualMachineScaleSetExtension + :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_07_01.models.VirtualMachineExtensionImage] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10908,14 +10346,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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = 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_extension_images_list_types_request( + location=location, + publisher_name=publisher_name, subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -10933,7 +10369,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("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10941,26 +10377,181 @@ def get( return deserialized # type: ignore @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) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + 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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + + _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) + + _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( + self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any + ) -> _models.VirtualMachineExtensionImage: + """Gets a virtual machine extension image. + + :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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + + _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) + + _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 + + +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` 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, **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_07_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-07-01")) + cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -10973,9 +10564,8 @@ 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_run_commands_list_request( + location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -11001,7 +10591,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) + deserialized = self._deserialize("RunCommandListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -11018,34 +10608,25 @@ 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) + @distributed_trace + def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: + """Gets specific run command for a subscription in a location. -class VirtualMachineScaleSetRollingUpgradesOperations: # 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_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_rolling_upgrades` 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 _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: + :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_07_01.models.RunCommandDocument + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11058,11 +10639,11 @@ def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kw _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.RunCommandDocument] = 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_run_commands_get_request( + location=location, + command_id=command_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, @@ -11070,23 +10651,18 @@ def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kw ) _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("RunCommandDocument", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -11094,60 +10670,118 @@ def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kw 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. + 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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[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.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-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 + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - 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, + 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 ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - def _start_os_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: + 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_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. + + :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_07_01.models.VirtualMachineRunCommand + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11160,99 +10794,45 @@ 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-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_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, + 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 = 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("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @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. - - :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] - :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-07-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, **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_extension_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any + 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, @@ -11262,17 +10842,30 @@ def _start_extension_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-07-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_extension_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, + 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, ) @@ -11286,7 +10879,7 @@ def _start_extension_upgrade_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): @@ -11294,153 +10887,167 @@ def _start_extension_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 == 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_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. + @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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[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_07_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_07_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-07-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, + @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_07_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_07_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_07_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-07-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._create_or_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) - 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 - - @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. 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_07_01.models.RollingUpgradeStatusInfo - :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-07-01")) - cls: ClsType[_models.RollingUpgradeStatusInfo] = 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, - 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 + return LROPoller[_models.VirtualMachineRunCommand]( + 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("RollingUpgradeStatusInfo", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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_07_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") - - def _create_or_update_initial( + def _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]], + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -11461,16 +11068,15 @@ 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(run_command, (IOBase, bytes)): + _content = run_command else: - _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") + _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") - _request = build_virtual_machine_scale_set_vm_extensions_create_or_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_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, @@ -11489,7 +11095,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]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -11497,112 +11103,109 @@ 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 = {} + 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_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineScaleSetVMExtension, + vm_name: str, + run_command_name: str, + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + ) -> 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 - :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_07_01.models.VirtualMachineScaleSetVMExtension + :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_07_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 VirtualMachineScaleSetVMExtension or the - result of cls(response) + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, - vm_scale_set_name: str, - instance_id: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_name: str, + run_command_name: str, + run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + ) -> 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 - :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_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 VirtualMachineScaleSetVMExtension or the - result of cls(response) + :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of + cls(response) :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_create_or_update( + def begin_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]], + vm_name: str, + run_command_name: str, + run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: - """The operation to create or update the VMSS VM extension. + ) -> 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 - :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_07_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] - :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 + :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_07_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_07_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -11610,17 +11213,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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.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._create_or_update_initial( + 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, + 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, @@ -11632,36 +11234,37 @@ 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) + 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: polling_method = polling if cont_token: - return LROPoller[_models.VirtualMachineScaleSetVMExtension].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[_models.VirtualMachineScaleSetVMExtension]( + return LROPoller[_models.VirtualMachineRunCommand]( 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 + def _delete_initial( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -11671,31 +11274,18 @@ 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-07-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") - - _request = build_virtual_machine_scale_set_vm_extensions_update_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_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, ) @@ -11709,7 +11299,7 @@ def _update_initial( 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): @@ -11717,167 +11307,297 @@ 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_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 begin_delete( + self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any + ) -> LROPoller[None]: + """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_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_07_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) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] + :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 = 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-07-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, + run_command_name=run_command_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 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_07_01.models.VirtualMachineScaleSetVMExtension] + 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 UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`usage` 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, **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 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_07_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-07-01")) + cls: ClsType[_models.ListUsagesResult] = 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_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 + + 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) + + 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) + 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 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_07_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_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. + 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 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_07_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-07-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 + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - :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_07_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the - result of cls(response) + 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.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] :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-07-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) - - 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 - ) + cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) - 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, 404: ResourceNotFoundError, @@ -11886,132 +11606,160 @@ def _delete_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-07-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_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, - 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, 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) + _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_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. + 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 - :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] + :return: An iterator like instance of either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-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, - 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 - ) - 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 + 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_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("VirtualMachineScaleSetListResult", 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, **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 + + 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, - instance_id: str, - vm_extension_name: str, *, - expand: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, **kwargs: Any - ) -> _models.VirtualMachineScaleSetVMExtension: - """The operation to get the VMSS VM extension. + ) -> _models.VirtualMachineScaleSet: + """Display information about a 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 - :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_07_01.models.VirtualMachineScaleSetVMExtension + :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_07_01.models.ExpandTypesForGetVMScaleSets + :return: VirtualMachineScaleSet or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12026,13 +11774,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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vm_extensions_get_request( + _request = build_virtual_machine_scale_sets_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, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, @@ -12052,37 +11798,23 @@ 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("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], *, - expand: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: 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. 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_07_01.models.VirtualMachineScaleSetVMExtensionsListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12091,73 +11823,236 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = 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_list_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, - expand=expand, + 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) - _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) - deserialized = self._deserialize( - "VirtualMachineScaleSetVMExtensionsListResult", 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 + 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 + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. -class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """ - .. 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 parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_scale_set_vms` attribute. - """ + @overload + 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 + ) -> LROPoller[_models.VirtualMachineScaleSet]: + """Create or update a VM scale set. - models = _models + :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_07_01.models.VirtualMachineScaleSet] + :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_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, + **kwargs: Any + ) -> LROPoller[_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. Is either a VirtualMachineScaleSet type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] + :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-07-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, 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.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 _reimage_initial( + def _update_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, + parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], + *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -12178,19 +12073,17 @@ def _reimage_initial( 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 + if isinstance(parameters, (IOBase, bytes)): + _content = parameters 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 + _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") - _request = build_virtual_machine_scale_set_vms_reimage_request( + _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, @@ -12208,7 +12101,7 @@ def _reimage_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): @@ -12216,119 +12109,275 @@ 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 = {} + 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_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, + parameters: _models.VirtualMachineScaleSetUpdate, *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in 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 - :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_07_01.models.VirtualMachineScaleSetVMReimageParameters + :param parameters: The scale set object. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_reimage( + def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, + parameters: IO[bytes], *, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific virtual machine in 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 - :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] + :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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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 + ) -> 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. Is either a VirtualMachineScaleSetUpdate type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_01.models.VirtualMachineScaleSet] :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-07-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): + 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, 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.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, + 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-07-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_machine_scale_sets_delete_request( + resource_group_name=resource_group_name, + vm_scale_set_name=vm_scale_set_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 + ) + + 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_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_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: - """Reimages (upgrade the operating system) a specific 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 - :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_07_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] + :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 = 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-07-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, + force_deletion=force_deletion, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -12342,7 +12391,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: @@ -12356,8 +12407,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 _reimage_all_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, @@ -12367,18 +12422,32 @@ def _reimage_all_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-07-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_reimage_all_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, ) @@ -12392,52 +12461,125 @@ def _reimage_all_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): pass 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) + + 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_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 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_07_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_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_reimage_all( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + 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]: - """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. + """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_07_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 = 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-07-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_all_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, @@ -12451,7 +12593,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: @@ -12465,9 +12609,85 @@ 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 _approve_rolling_upgrade_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Iterator[bytes]: + @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_07_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_07_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, @@ -12476,108 +12696,56 @@ 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-07-01")) - cls: ClsType[Iterator[bytes]] = 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_approve_rolling_upgrade_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, 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]: 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")) - - 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_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. - - :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-07-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) - - 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 + return cls(pipeline_response, None, {}) # type: ignore def _deallocate_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + 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, @@ -12587,18 +12755,33 @@ 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-07-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_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_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, ) @@ -12620,35 +12803,125 @@ 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 + 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 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_07_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: + """ + + @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, instance_id: str, **kwargs: Any + 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 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. + """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. Is + either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. + :type vm_instance_i_ds: + ~azure.mgmt.compute.v2024_07_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 = 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-07-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) @@ -12657,8 +12930,10 @@ def begin_deallocate( 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, @@ -12672,7 +12947,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: @@ -12686,15 +12963,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 - def _update_initial( + def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -12715,18 +12990,16 @@ 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, "VirtualMachineScaleSetVM") + _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") - _request = build_virtual_machine_scale_set_vms_update_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, - if_match=if_match, - if_none_match=if_none_match, + force_deletion=force_deletion, api_version=api_version, content_type=content_type, json=_json, @@ -12752,135 +13025,109 @@ 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_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.VirtualMachineScaleSetVM, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[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 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_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 parameters: ~azure.mgmt.compute.v2024_07_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 vm_instance_i_ds: + ~azure.mgmt.compute.v2024_07_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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM] + :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_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_instance_i_ds: IO[bytes], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[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 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. + :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. 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 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 VirtualMachineScaleSetVM or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVM] + :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_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], *, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, + force_deletion: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineScaleSetVM]: - """Updates a virtual machine of a VM scale set. + ) -> LROPoller[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 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_07_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_07_01.models.VirtualMachineScaleSetVM] + :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_07_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 {}) @@ -12888,18 +13135,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineScaleSetVM] = 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._delete_instances_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_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, @@ -12910,36 +13155,166 @@ 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("VirtualMachineScaleSetVM", 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.VirtualMachineScaleSetVM].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.VirtualMachineScaleSetVM]( - 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 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_07_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-07-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) - def _delete_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("RecoveryWalkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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. + + :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_07_01.models.VirtualMachineScaleSetInstanceView + :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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) + + _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) + + _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("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - *, - force_deletion: Optional[bool] = None, + vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -12950,19 +13325,29 @@ 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-07-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( + 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_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, - force_deletion=force_deletion, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -12976,7 +13361,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): @@ -12984,53 +13369,114 @@ 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( + @overload + def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, - force_deletion: Optional[bool] = None, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: - """Deletes a virtual machine from a VM scale set. + """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 - :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_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_07_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] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @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. 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 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. 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_07_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-07-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._update_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - force_deletion=force_deletion, + 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, @@ -13044,7 +13490,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: @@ -13059,172 +13507,27 @@ 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, - 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. Known values are: "instanceView" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: VirtualMachineScaleSetVM or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVM] = 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) - - _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("VirtualMachineScaleSetVM", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # 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. - - :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_07_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-07-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. + 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. 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 - cls(response) + :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_07_01.models.VirtualMachineScaleSetVM] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13237,13 +13540,10 @@ 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_get_os_upgrade_history_request( resource_group_name=resource_group_name, - virtual_machine_scale_set_name=virtual_machine_scale_set_name, + vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, - filter=filter, - select=select, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -13268,7 +13568,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) + deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -13291,13 +13591,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _power_off_initial( + def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - *, - skip_shutdown: bool = False, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -13308,19 +13606,32 @@ def _power_off_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-07-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_power_off_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_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, - skip_shutdown=skip_shutdown, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -13342,165 +13653,123 @@ 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( + @overload + def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, - skip_shutdown: bool = False, + content_type: str = "application/json", **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. + """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 - :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 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_07_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 {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, **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, 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-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_virtual_machine_scale_set_vms_restart_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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @overload + def begin_perform_maintenance( + 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]: + """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. - 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 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, instance_id: str, **kwargs: Any + def begin_perform_maintenance( + 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 a virtual machine in a VM scale set. + """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 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_07_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 = 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-07-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._perform_maintenance_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, @@ -13514,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: @@ -13528,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 _start_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + def _power_off_initial( + self, + resource_group_name: str, + 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 = { 401: ClientAuthenticationError, @@ -13539,18 +13816,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-07-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_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, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) @@ -13572,43 +13864,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 + @overload + def begin_power_off( + self, + resource_group_name: str, + 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[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. 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_07_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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_power_off( + self, + resource_group_name: str, + 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[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. 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 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def begin_start( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + def begin_power_off( + self, + resource_group_name: str, + vm_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + *, + skip_shutdown: Optional[bool] = None, + **kwargs: Any ) -> LROPoller[None]: - """Starts a virtual machine in a VM scale set. + """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_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_07_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 = 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-07-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._power_off_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, + skip_shutdown=skip_shutdown, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -13622,7 +14008,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,9 +14024,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 _redeploy_initial( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **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, @@ -13653,10 +14039,9 @@ def _redeploy_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_scale_set_vms_redeploy_request( + _request = build_virtual_machine_scale_sets_reapply_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, @@ -13680,26 +14065,28 @@ 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 @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. + 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. + :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: @@ -13713,10 +14100,9 @@ def begin_redeploy( 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._reapply_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, @@ -13731,7 +14117,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: @@ -13745,79 +14133,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 - @distributed_trace - def retrieve_boot_diagnostics_data( + def _redeploy_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - *, - sas_uri_expiration_time_in_minutes: Optional[int] = None, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = 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. 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_07_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-07-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) - - _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 _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, @@ -13827,18 +14148,32 @@ 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-07-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_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_redeploy_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, ) @@ -13860,43 +14195,117 @@ def _perform_maintenance_initial( 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) + 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[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 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_07_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: + """ - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + @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. - 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 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_perform_maintenance( - self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any + 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 ) -> LROPoller[None]: - """Performs maintenance on a virtual machine in a VM scale set. + """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_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_07_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 = 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-07-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._redeploy_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, @@ -13910,7 +14319,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: @@ -13924,67 +14335,11 @@ 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_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. 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-07-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 _attach_detach_data_disks_initial( + def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14005,15 +14360,17 @@ 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_scale_set_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_reimage_input else: - _json = self._serialize.body(parameters, "AttachDetachDataDisksRequest") + 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_set_vms_attach_detach_data_disks_request( + _request = build_virtual_machine_scale_sets_reimage_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, @@ -14043,6 +14400,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) @@ -14052,92 +14410,87 @@ def _attach_detach_data_disks_initial( return deserialized # type: ignore @overload - def begin_attach_detach_data_disks( + def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: _models.AttachDetachDataDisksRequest, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, *, 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]: + """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_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_07_01.models.AttachDetachDataDisksRequest + :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_07_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 StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_reimage( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: IO[bytes], + vm_scale_set_reimage_input: Optional[IO[bytes]] = None, *, 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]: + """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_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_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 StorageProfile or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_reimage( self, resource_group_name: str, vm_scale_set_name: str, - instance_id: str, - parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.StorageProfile]: - """Attach and detach data disks to/from a virtual machine in a VM scale set. + ) -> 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. 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_07_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_07_01.models.StorageProfile] + :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_07_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 {}) @@ -14145,16 +14498,15 @@ def begin_attach_detach_data_disks( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._reimage_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, - instance_id=instance_id, - parameters=parameters, + vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -14165,11 +14517,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( @@ -14180,22 +14530,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 _run_command_initial( + def _reimage_all_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 = { @@ -14216,15 +14563,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_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, content_type=content_type, @@ -14251,96 +14600,99 @@ 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_reimage_all( 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]: + """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_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_07_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_07_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_07_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_reimage_all( 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]: + """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_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_07_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_reimage_all( 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]: + """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_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_07_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_07_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_07_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 {}) @@ -14348,16 +14700,15 @@ def begin_run_command( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._reimage_all_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, @@ -14368,11 +14719,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( @@ -14383,43 +14732,19 @@ 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_07_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 _restart_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 ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14440,15 +14765,17 @@ 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_restart_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, @@ -14467,7 +14794,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): @@ -14475,105 +14802,96 @@ 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_restart( 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 - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> 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 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_07_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_07_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_restart( 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 - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> 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 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 LROPoller that returns either VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_restart( 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 - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to create or update the extension. + ) -> 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 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_07_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_07_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_07_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 {}) @@ -14581,16 +14899,15 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._restart_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, @@ -14600,36 +14917,33 @@ 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( + def _set_orchestration_service_state_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, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -14650,15 +14964,14 @@ 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, "VirtualMachineExtensionUpdate") + _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") - _request = build_virtual_machine_extensions_update_request( + _request = build_virtual_machine_scale_sets_set_orchestration_service_state_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, @@ -14677,7 +14990,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): @@ -14685,106 +14998,93 @@ 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_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: _models.VirtualMachineExtensionUpdate, + vm_scale_set_name: str, + parameters: _models.OrchestrationServiceStateInput, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> 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_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_07_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 parameters: The input object for SetOrchestrationServiceState API. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_update( + def begin_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: IO[bytes], + vm_scale_set_name: str, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> 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_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 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 VirtualMachineExtension or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_set_orchestration_service_state( self, resource_group_name: str, - vm_name: str, - vm_extension_name: str, - extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], + vm_scale_set_name: str, + parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.VirtualMachineExtension]: - """The operation to update the extension. + ) -> 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_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_07_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_07_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 parameters: The input object for SetOrchestrationServiceState API. Is either a + OrchestrationServiceStateInput type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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 {}) @@ -14792,16 +15092,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._set_orchestration_service_state_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, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -14812,31 +15111,119 @@ 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 + @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_07_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-07-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_scale_set_name: str, + vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, + **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14846,18 +15233,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-07-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_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_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, ) @@ -14871,7 +15272,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): @@ -14879,44 +15280,114 @@ 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_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]: - """The operation to delete the extension. + """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 where the extension should be deleted. + :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_07_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_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. + + :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_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: """ - _headers = kwargs.pop("headers", {}) or {} + + @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. + + :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_07_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-07-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._start_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_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, @@ -14930,7 +15401,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: @@ -14944,90 +15417,43 @@ 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, - 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. - :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_07_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-07-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 = 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) +class VirtualMachinesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_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 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. + 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 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_07_01.models.VirtualMachineExtensionsListResult + :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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15036,69 +15462,85 @@ def list( } 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-07-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) + def prepare_request(next_link=None): + if not next_link: - deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) + _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) - if cls: - return cls(pipeline_response, 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 - return deserialized # type: ignore + 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) -class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + _stream = False + pipeline_response: PipelineResponse = 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_07_01.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - models = _models + return pipeline_response - 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 ItemPaged(get_next, extract_data) @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. + 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. - :param location: The location for which virtual machines under the subscription are queried. - Required. - :type location: str + :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_07_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_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: @@ -15120,9 +15562,11 @@ 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_machines_list_by_location_request( - location=location, + _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, @@ -15170,13 +15614,41 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _capture_initial( + @distributed_trace + def list( self, resource_group_name: str, - vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + *, + filter: Optional[str] = None, + expand: Optional[Union[str, _models.ExpandTypeForListVMs]] = None, **kwargs: Any - ) -> Iterator[bytes]: + ) -> 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_07_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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15185,189 +15657,130 @@ def _capture_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-07-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, "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, - ) - _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 + def prepare_request(next_link=None): + if not 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) + _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) - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + 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("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) - return deserialized # type: ignore + def get_next(next_link=None): + _request = prepare_request(next_link) - @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. + _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 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_07_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_07_01.models.VirtualMachineCaptureResult] - :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 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. + return pipeline_response - :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 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_07_01.models.VirtualMachineCaptureResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_capture( + def get( self, resource_group_name: str, vm_name: str, - parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], + *, + expand: Optional[Union[str, _models.InstanceViewTypes]] = 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. + ) -> _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 - :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_07_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_07_01.models.VirtualMachineCaptureResult] + :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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: VirtualMachine or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachine :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-07-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) + cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + _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) - 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.VirtualMachineCaptureResult].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 + _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("VirtualMachine", 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, @@ -15432,10 +15845,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 @@ -15454,7 +15872,8 @@ def begin_create_or_update( """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 @@ -15492,7 +15911,8 @@ def begin_create_or_update( """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 @@ -15529,7 +15949,8 @@ def begin_create_or_update( """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 @@ -15582,7 +16003,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: @@ -15662,10 +16085,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 @@ -15683,7 +16110,8 @@ def begin_update( ) -> 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 @@ -15720,7 +16148,8 @@ def begin_update( ) -> 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 @@ -15739,174 +16168,62 @@ def begin_update( :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_07_01.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - 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. - :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_07_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_07_01.models.VirtualMachine] - :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-07-01")) - 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._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, - **kwargs - ) - 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) - 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.VirtualMachine].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-07-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 - ) - - 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 + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ @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 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 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] + :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_07_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_07_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-07-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._delete_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, - 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, @@ -15915,151 +16232,38 @@ 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("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 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" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: VirtualMachine or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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-07-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 = 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 - 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_07_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-07-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 + return LROPoller[_models.VirtualMachine]( + 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("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 _delete_initial( + self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -16075,10 +16279,11 @@ def _convert_to_managed_disks_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_convert_to_managed_disks_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, @@ -16093,7 +16298,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, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -16101,22 +16306,32 @@ 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 == 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_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_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 :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: @@ -16130,9 +16345,10 @@ def begin_convert_to_managed_disks(self, resource_group_name: str, vm_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._convert_to_managed_disks_initial( + 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, @@ -16147,7 +16363,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: @@ -16161,9 +16379,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 _deallocate_initial( - self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **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, @@ -16178,11 +16394,10 @@ def _deallocate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_deallocate_request( + _request = build_virtual_machines_assess_patches_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, @@ -16205,43 +16420,47 @@ 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 @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_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. 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] + :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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-07-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._deallocate_initial( + raw_result = self._assess_patches_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, @@ -16251,44 +16470,38 @@ 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): + 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 - - @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.VirtualMachineAssessPatchesResult]( + 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 _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, @@ -16297,316 +16510,199 @@ def generalize( # 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-07-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_virtual_machines_generalize_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, ) _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) - if cls: - return cls(pipeline_response, None, {}) # 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. - - :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_07_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_07_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-07-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 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_07_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_07_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-07-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 + 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")) - 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 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. + @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. 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) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineSize] + :param parameters: Parameters supplied to the attach and detach data disks operation on the + virtual machine. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_01.models.StorageProfile] :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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + @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. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :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_07_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @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. - _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) + :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_07_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_07_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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 + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, 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( + 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 extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageProfile", pipeline_response.http_response) 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) + 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) ) - 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[_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.StorageProfile]( + 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 + 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, @@ -16616,18 +16712,29 @@ def _power_off_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-07-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_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, "VirtualMachineCaptureParameters") + + _request = build_virtual_machines_capture_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, ) @@ -16649,48 +16756,120 @@ 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 + + @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. 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_07_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_07_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. - 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 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_07_01.models.VirtualMachineCaptureResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @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. + 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. 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 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 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_07_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_07_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-07-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, 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._capture_initial( resource_group_name=resource_group_name, vm_name=vm_name, - skip_shutdown=skip_shutdown, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -16699,26 +16878,34 @@ 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("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 _reapply_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, @@ -16733,7 +16920,7 @@ def _reapply_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-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_reapply_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, @@ -16759,18 +16946,25 @@ 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 @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_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 @@ -16787,7 +16981,7 @@ def begin_reapply(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._reapply_initial( + raw_result = self._convert_to_managed_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -16804,7 +16998,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: @@ -16818,7 +17014,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 _restart_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, @@ -16833,10 +17031,11 @@ def _restart_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-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_restart_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, @@ -16859,21 +17058,32 @@ 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. + 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: @@ -16887,9 +17097,10 @@ def begin_restart(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._restart_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, @@ -16904,7 +17115,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: @@ -16918,7 +17131,26 @@ 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_name: str, **kwargs: Any) -> Iterator[bytes]: + @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, @@ -16931,13 +17163,70 @@ def _start_initial(self, resource_group_name: str, vm_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-07-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, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + **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-07-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_start_request( + 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( 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, ) @@ -16959,38 +17248,120 @@ 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 + @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. 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. + Required. + :type install_patches_input: + ~azure.mgmt.compute.v2024_07_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_07_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. 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. + 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_07_01.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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_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. - :param resource_group_name: The name of the resource 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 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_07_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_07_01.models.VirtualMachineInstallPatchesResult] :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-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", 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._start_initial( + raw_result = self._install_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, + install_patches_input=install_patches_input, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -16999,26 +17370,46 @@ def begin_start(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("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 + ) - def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + @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. 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_07_01.models.VirtualMachineInstanceView + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17031,9 +17422,9 @@ def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: An _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) - _request = build_virtual_machines_redeploy_request( + _request = build_virtual_machines_instance_view_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17043,88 +17434,25 @@ def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: An ) _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("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # 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. - - :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 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-07-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_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, **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_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **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, @@ -17133,32 +17461,17 @@ 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-07-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, "VirtualMachineReimageParameters") - else: - _json = None - - _request = build_virtual_machines_reimage_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, ) @@ -17180,120 +17493,44 @@ 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_name: str, - parameters: Optional[_models.VirtualMachineReimageParameters] = None, - *, - 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. - - :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 Reimage Virtual Machine operation. Default value - is None. - :type parameters: ~azure.mgmt.compute.v2024_07_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 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_name: str, - parameters: Optional[IO[bytes]] = None, - *, - 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. - - :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 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 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_name: str, - parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, - **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. + 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 - :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_07_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: """ - _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-07-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._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, @@ -17307,7 +17544,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: @@ -17321,29 +17560,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 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_07_01.models.RetrieveBootDiagnosticsDataResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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, 404: ResourceNotFoundError, @@ -17356,38 +17575,111 @@ 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-07-01")) - cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( + _request = build_virtual_machines_power_off_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, + 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 = 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("RetrieveBootDiagnosticsDataResult", 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 _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: + @distributed_trace + 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. 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 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-07-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_name=vm_name, + 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 _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17402,7 +17694,7 @@ def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_perform_maintenance_request( + _request = build_virtual_machines_reapply_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17428,18 +17720,24 @@ 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 = {} + 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_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_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 @@ -17456,7 +17754,7 @@ def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kw 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._reapply_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -17473,7 +17771,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: @@ -17487,59 +17787,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-07-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 _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17554,7 +17802,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-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machines_assess_patches_request( + _request = build_virtual_machines_redeploy_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17580,39 +17828,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_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 - :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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-07-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._redeploy_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, @@ -17624,11 +17874,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( @@ -17639,21 +17887,19 @@ 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( + def _reimage_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -17674,12 +17920,15 @@ def _install_patches_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(install_patches_input, (IOBase, bytes)): - _content = install_patches_input + if isinstance(parameters, (IOBase, bytes)): + _content = parameters else: - _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") + if parameters is not None: + _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") + else: + _json = None - _request = build_virtual_machines_install_patches_request( + _request = build_virtual_machines_reimage_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, @@ -17708,94 +17957,110 @@ 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( + def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. - :param resource_group_name: The name of the resource 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. - Required. - :type install_patches_input: - ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesParameters + :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value + is None. + :type parameters: ~azure.mgmt.compute.v2024_07_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 LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesResult] + :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_install_patches( + def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: IO[bytes], + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. - :param resource_group_name: The name of the resource 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. - Required. - :type install_patches_input: IO[bytes] + :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 LROPoller that returns either VirtualMachineInstallPatchesResult or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineInstallPatchesResult] + :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_install_patches( + def begin_reimage( self, resource_group_name: str, vm_name: str, - install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], + parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any - ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: - """Installs patches on the VM. + ) -> 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. - :param resource_group_name: The name of the resource 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_07_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_07_01.models.VirtualMachineInstallPatchesResult] + :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_07_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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -17803,15 +18068,15 @@ def begin_install_patches( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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._reimage_initial( resource_group_name=resource_group_name, vm_name=vm_name, - install_patches_input=install_patches_input, + parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -17822,11 +18087,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( @@ -17837,23 +18100,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 _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -17862,29 +18117,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-07-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_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, ) @@ -17909,6 +18152,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) @@ -17917,101 +18161,32 @@ 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. - - :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: ~azure.mgmt.compute.v2024_07_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_07_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. 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_07_01.models.StorageProfile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @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_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 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_07_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_07_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-07-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._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, @@ -18020,31 +18195,94 @@ 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( + 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 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. 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_07_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-07-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) - 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.StorageProfile].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 + _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, @@ -18104,10 +18342,15 @@ 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 @@ -18123,7 +18366,8 @@ def begin_run_command( ) -> LROPoller[_models.RunCommandResult]: """Run command 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 @@ -18150,14 +18394,15 @@ def begin_run_command( ) -> LROPoller[_models.RunCommandResult]: """Run command 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 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". + Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) @@ -18175,7 +18420,8 @@ def begin_run_command( ) -> LROPoller[_models.RunCommandResult]: """Run command 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 @@ -18236,185 +18482,19 @@ def get_long_running_output(pipeline_response): 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_07_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 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_07_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-07-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( - 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 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_07_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-07-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 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. + 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 - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_07_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 = { @@ -18429,11 +18509,11 @@ 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-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_offers_request( - location=location, - 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, @@ -18448,27 +18528,14 @@ 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 - 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 a supported Azure region. Required. - :type location: str - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineImageResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18481,10 +18548,11 @@ def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualM _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_list_publishers_request( - location=location, + _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, @@ -18492,40 +18560,111 @@ def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualM ) _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_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 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 - :return: list of VirtualMachineImageResource or the result of cls(response) - :rtype: list[~azure.mgmt.compute.v2024_07_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 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-07-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_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_07_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-07-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18534,53 +18673,98 @@ def list_skus( } 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-07-01")) - cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) + _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) - _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, - 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("[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) + + +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` 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_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. + 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 - :return: VmImagesInEdgeZoneListResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.VmImagesInEdgeZoneListResult + :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18589,49 +18773,69 @@ def list_by_edge_zone(self, location: str, edge_zone: str, **kwargs: Any) -> _mo } 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-07-01")) - cls: ClsType[_models.VmImagesInEdgeZoneListResult] = 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_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) + 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("VmImagesInEdgeZoneListResult", pipeline_response.http_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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 VirtualMachineImagesEdgeZoneOperations: +class ProximityPlacementGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_images_edge_zone` attribute. + :attr:`proximity_placement_groups` attribute. """ models = _models @@ -18645,27 +18849,21 @@ 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_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 - :param version: A valid image SKU version. Required. - :type version: str - :return: VirtualMachineImage or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineImage + :return: An iterator like instance of either ProximityPlacementGroup or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -18674,81 +18872,161 @@ def get( } 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) + + 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. 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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) + cls: ClsType[_models.ProximityPlacementGroupListResult] = 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) + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = 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_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) - 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("VirtualMachineImage", pipeline_response.http_response) + 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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + def get_next(next_link=None): + _request = prepare_request(next_link) - return deserialized # 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def list( + def get( self, - location: str, - edge_zone: str, - publisher_name: str, - offer: str, - skus: str, + resource_group_name: str, + proximity_placement_group_name: str, *, - expand: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + include_colocation_status: 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. + ) -> _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 - :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_07_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_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18763,18 +19041,13 @@ 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-07-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_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, - skus=skus, + _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, - expand=expand, - top=top, - orderby=orderby, + include_colocation_status=include_colocation_status, api_version=api_version, headers=_headers, params=_params, @@ -18792,28 +19065,89 @@ 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("[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. + + :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_07_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_07_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. 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_07_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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 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 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_07_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 + :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_07_01.models.ProximityPlacementGroup or IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18824,18 +19158,29 @@ def list_offers( } 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-07-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.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_offers_request( - location=location, - edge_zone=edge_zone, - 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, "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, ) @@ -18848,29 +19193,94 @@ def list_offers( 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("[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 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_07_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_07_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_07_01.models.ProximityPlacementGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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. + 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 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_07_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 + :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_07_01.models.ProximityPlacementGroupUpdate or + IO[bytes] + :return: ProximityPlacementGroup or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -18881,17 +19291,29 @@ def list_publishers( } 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-07-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.ProximityPlacementGroup] = kwargs.pop("cls", None) - _request = build_virtual_machine_images_edge_zone_list_publishers_request( - location=location, - edge_zone=edge_zone, + 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, ) @@ -18908,7 +19330,7 @@ def list_publishers( 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 @@ -18916,22 +19338,18 @@ def list_publishers( return deserialized # type: ignore @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 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_07_01.models.VirtualMachineImageResource] + 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. 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 = { @@ -18946,13 +19364,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-07-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_skus_request( - location=location, - edge_zone=edge_zone, - publisher_name=publisher_name, - offer=offer, + _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, api_version=api_version, headers=_headers, @@ -18971,22 +19387,18 @@ 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) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore -class VirtualMachineExtensionImagesOperations: +class RestorePointCollectionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_extension_images` attribute. + :attr:`restore_point_collections` attribute. """ models = _models @@ -19000,23 +19412,23 @@ 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, publisher_name: str, type: str, version: str, **kwargs: Any - ) -> _models.VirtualMachineExtensionImage: - """Gets a virtual machine extension image. + 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 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_07_01.models.VirtualMachineExtensionImage + :return: An iterator like instance of either RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19025,56 +19437,77 @@ 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-07-01")) - cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) + _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_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 = 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("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 ItemPaged(get_next, extract_data) @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 list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: + """Gets the list of restore point collections 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_07_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 RestorePointCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) + cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19083,68 +19516,82 @@ 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-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + _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) - _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 = 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("[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 ItemPaged(get_next, extract_data) @distributed_trace - def list_versions( + def get( self, - location: str, - publisher_name: str, - type: str, + resource_group_name: str, + restore_point_collection_name: str, *, - filter: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, + expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, **kwargs: Any - ) -> List[_models.VirtualMachineExtensionImage]: - """Gets a list of virtual machine extension image versions. + ) -> _models.RestorePointCollection: + """The operation to get the restore point collection. - :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_07_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 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_07_01.models.RestorePointCollectionExpandOptions + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19159,16 +19606,13 @@ 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-07-01")) - cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) + cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) - _request = build_virtual_machine_extension_images_list_versions_request( - location=location, - publisher_name=publisher_name, - type=type, + _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, - filter=filter, - top=top, - orderby=orderby, + expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -19186,57 +19630,40 @@ 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("RestorePointCollection", 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_07_01.ComputeManagementClient`'s - :attr:`availability_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") - @overload def create_or_update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySet, + restore_point_collection_name: str, + parameters: _models.RestorePointCollection, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :param parameters: Parameters supplied to the Create Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -19244,25 +19671,29 @@ def create_or_update( def create_or_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 - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :param parameters: Parameters supplied to the Create Availability Set operation. Required. + :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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -19270,21 +19701,24 @@ def create_or_update( def create_or_update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySet, IO[bytes]], + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollection, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Create or update an availability set. + ) -> _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 - :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_07_01.models.AvailabilitySet or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.RestorePointCollection or IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19300,7 +19734,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -19308,11 +19742,11 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "AvailabilitySet") + _json = self._serialize.body(parameters, "RestorePointCollection") - _request = build_availability_sets_create_or_update_request( + _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, @@ -19330,11 +19764,11 @@ 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("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -19345,25 +19779,27 @@ def create_or_update( def update( self, resource_group_name: str, - availability_set_name: str, - parameters: _models.AvailabilitySetUpdate, + restore_point_collection_name: str, + parameters: _models.RestorePointCollectionUpdate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySetUpdate + :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_07_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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -19371,25 +19807,27 @@ def update( 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 - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Required. + :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: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @@ -19397,21 +19835,23 @@ def update( def update( self, resource_group_name: str, - availability_set_name: str, - parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], + restore_point_collection_name: str, + parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], **kwargs: Any - ) -> _models.AvailabilitySet: - """Update an availability set. + ) -> _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 Update Availability Set operation. Is either a - AvailabilitySetUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_01.models.AvailabilitySetUpdate or IO[bytes] - :return: AvailabilitySet or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 Update restore point collection operation. Is + either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollectionUpdate or + IO[bytes] + :return: RestorePointCollection or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19427,7 +19867,7 @@ def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -19435,11 +19875,11 @@ def update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "AvailabilitySetUpdate") + _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") - _request = build_availability_sets_update_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, @@ -19461,77 +19901,16 @@ 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. - - :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 - :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-07-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) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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. 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_07_01.models.AvailabilitySet - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _delete_initial( + self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19544,11 +19923,11 @@ def get(self, resource_group_name: str, availability_set_name: str, **kwargs: An _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_availability_sets_get_request( + _request = build_restore_point_collections_delete_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, headers=_headers, @@ -19556,42 +19935,129 @@ def get(self, resource_group_name: str, availability_set_name: str, **kwargs: An ) _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("AvailabilitySet", 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, *, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySet"]: - """Lists all availability sets in a subscription. + 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. - :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_07_01.models.AvailabilitySet] + :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 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-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = 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_07_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_07_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-07-01")) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -19604,9 +20070,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_ssh_public_keys_list_by_subscription_request( subscription_id=self._config.subscription_id, - expand=expand, api_version=api_version, headers=_headers, params=_params, @@ -19631,7 +20096,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -19655,20 +20120,26 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AvailabilitySet"]: - """Lists all availability sets in a resource group. + 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. + :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.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.AvailabilitySet] + :return: An iterator like instance of either SshPublicKeyResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -19681,7 +20152,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Ava def prepare_request(next_link=None): if not next_link: - _request = build_availability_sets_list_request( + _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, @@ -19708,7 +20179,7 @@ def prepare_request(next_link=None): return _request def extract_data(pipeline_response): - deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) + deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -19732,26 +20203,18 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @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 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 - :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineSize] + :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_07_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-07-01")) - cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -19760,154 +20223,114 @@ def list_available_sizes( } error_map.update(kwargs.pop("error_map", {}) or {}) - 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, - 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 - ) - 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-07-01")) + cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) - return pipeline_response + _request = build_ssh_public_keys_get_request( + resource_group_name=resource_group_name, + ssh_public_key_name=ssh_public_key_name, + subscription_id=self._config.subscription_id, + 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 ProximityPlacementGroupsOperations: - """ - .. 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_07_01.ComputeManagementClient`'s - :attr:`proximity_placement_groups` attribute. - """ + deserialized = self._deserialize("SshPublicKeyResource", 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 @overload - def create_or_update( + 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_07_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_07_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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + 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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def create( self, resource_group_name: str, - proximity_placement_group_name: str, - parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], + ssh_public_key_name: str, + parameters: Union[_models.SshPublicKeyResource, IO[bytes]], **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. + :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_07_01.models.ProximityPlacementGroup or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.SshPublicKeyResource or IO[bytes] + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -19923,7 +20346,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -19931,11 +20354,11 @@ 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, @@ -19957,7 +20380,7 @@ 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 @@ -19968,26 +20391,26 @@ def create_or_update( 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_07_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_07_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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -19995,26 +20418,26 @@ def update( 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_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @@ -20022,22 +20445,23 @@ def update( 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_07_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_07_01.models.SshPublicKeyUpdateResource or IO[bytes] - :return: ProximityPlacementGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.ProximityPlacementGroup + :return: SshPublicKeyResource or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20053,7 +20477,7 @@ def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -20061,11 +20485,11 @@ 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, @@ -20087,7 +20511,7 @@ 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 @@ -20096,14 +20520,15 @@ def update( @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any + self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any ) -> None: - """Delete a proximity placement group. + """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: @@ -20122,9 +20547,9 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -20139,33 +20564,94 @@ def delete( # pylint: disable=inconsistent-return-statements 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 - def get( + @overload + 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_07_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_07_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_07_01.models.SshPublicKeyGenerateKeyPairResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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. + + :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_07_01.models.SshPublicKeyGenerateKeyPairResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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_07_01.models.SshGenerateKeyPairInputParameters or + IO[bytes] + :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -20176,18 +20662,32 @@ 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-07-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, ) @@ -20204,28 +20704,56 @@ 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("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 + +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s + :attr:`capacity_reservations` 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.ProximityPlacementGroup"]: - """Lists all proximity placement groups in a subscription. + 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. - :return: An iterator like instance of either ProximityPlacementGroup 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 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_07_01.models.ProximityPlacementGroup] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20238,7 +20766,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ProximityPlac def prepare_request(next_link=None): if not next_link: - _request = build_proximity_placement_groups_list_by_subscription_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, @@ -20264,7 +20794,7 @@ def prepare_request(next_link=None): return _request 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 @@ -20288,25 +20818,85 @@ def get_next(next_link=None): 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. + def get( + self, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + *, + expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, + **kwargs: Any + ) -> _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 - :return: An iterator like instance of either ProximityPlacementGroup or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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_07_01.models.CapacityReservationInstanceViewTypes + :return: CapacityReservation or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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 {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + + _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 = 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 + 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, @@ -20315,159 +20905,218 @@ def list_by_resource_group( } 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) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + 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") - 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_capacity_reservations_create_or_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - return pipeline_response + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return ItemPaged(get_next, extract_data) + 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) -class DedicatedHostGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + 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")) - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`dedicated_host_groups` attribute. - """ + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - models = _models + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 @overload - def create_or_update( + def begin_create_or_update( self, - resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroup, + resource_group_name: str, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservation, *, 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). + ) -> 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 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_07_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. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + 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: - """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). + ) -> 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 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. + :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_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def begin_create_or_update( 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). + ) -> 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 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_07_01.models.DedicatedHostGroup or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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-07-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, @@ -20481,7 +21130,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -20489,11 +21138,12 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DedicatedHostGroup") + _json = self._serialize.body(parameters, "CapacityReservationUpdate") - _request = build_dedicated_host_groups_create_or_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, @@ -20504,165 +21154,182 @@ 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("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 - def update( + def begin_update( self, resource_group_name: str, - host_group_name: str, - parameters: _models.DedicatedHostGroupUpdate, + capacity_reservation_group_name: str, + capacity_reservation_name: str, + parameters: _models.CapacityReservationUpdate, *, content_type: str = "application/json", **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. Required. - :type parameters: ~azure.mgmt.compute.v2024_07_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 Update capacity reservation operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_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. + ) -> 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. 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_07_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_07_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_07_01.models.DedicatedHostGroupUpdate or IO[bytes] - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 Update capacity reservation operation. Is either + a CapacityReservationUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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 = 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-07-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, @@ -20675,11 +21342,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-07-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, @@ -20687,103 +21355,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" and "userData". - Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: DedicatedHostGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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-07-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_07_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_07_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_07_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-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -20796,8 +21503,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, @@ -20823,7 +21531,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 @@ -20847,20 +21555,32 @@ 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_07_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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: DedicatedHost or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -20869,78 +21589,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-07-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_07_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, @@ -21003,10 +21686,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 @@ -21023,11 +21711,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_07_01.models.DedicatedHost @@ -21053,11 +21742,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] @@ -21081,11 +21771,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. @@ -21127,7 +21818,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: @@ -21204,10 +21897,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 @@ -21224,11 +21921,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_07_01.models.DedicatedHostUpdate @@ -21254,11 +21952,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] @@ -21282,11 +21981,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. @@ -21322,13 +22022,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: @@ -21388,10 +22095,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 @@ -21401,7 +22113,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 @@ -21438,7 +22151,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: @@ -21453,95 +22168,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 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" and "userData". Default value is None. - :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes - :return: DedicatedHost or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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-07-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 - - return deserialized # 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_07_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-07-01")) - cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.DedicatedHostSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -21554,9 +22203,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, @@ -21582,7 +22232,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 @@ -21605,7 +22255,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - def _restart_initial( + def _redeploy_initial( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -21622,7 +22272,7 @@ def _restart_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_hosts_restart_request( + _request = build_dedicated_hosts_redeploy_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -21641,31 +22291,38 @@ def _restart_initial( response = pipeline_response.http_response - if response.status_code not in [200]: + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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( + def begin_redeploy( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> LROPoller[None]: - """Restart the dedicated host. The operation will complete successfully once the dedicated host - has restarted and is running. To determine the health of VMs deployed on the dedicated host - 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. + """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. 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 @@ -21684,7 +22341,7 @@ def begin_restart( 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._redeploy_initial( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -21702,7 +22359,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: @@ -21716,7 +22375,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 _redeploy_initial( + def _restart_initial( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { @@ -21733,7 +22392,7 @@ def _redeploy_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dedicated_hosts_redeploy_request( + _request = build_dedicated_hosts_restart_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -21752,7 +22411,7 @@ def _redeploy_initial( response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): @@ -21762,6 +22421,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) @@ -21771,16 +22431,16 @@ def _redeploy_initial( return deserialized # type: ignore @distributed_trace - def begin_redeploy( + def begin_restart( 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. + """Restart the dedicated host. The operation will complete successfully once the dedicated host + has restarted and is running. To determine the health of VMs deployed on the dedicated host + 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 @@ -21799,7 +22459,7 @@ def begin_redeploy( 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._restart_initial( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -21817,7 +22477,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: @@ -21831,102 +22493,15 @@ 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_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. - :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] - :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-07-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: +class RestorePointsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`ssh_public_keys` attribute. + :attr:`restore_points` attribute. """ models = _models @@ -21940,22 +22515,31 @@ def __init__(self, *args, **kwargs): 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 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. - :return: An iterator like instance of either SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource] + :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_07_01.models.RestorePointExpandOptions + :return: RestorePoint or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -21964,79 +22548,50 @@ 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: - - _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) - - 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) + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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-07-01")) + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - _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_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) - 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_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. + deserialized = self._deserialize("RestorePoint", 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 SshPublicKeyResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource] - :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-07-01")) - cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) + 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, 404: ResourceNotFoundError, @@ -22045,132 +22600,211 @@ def list_by_resource_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_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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RestorePoint") - 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) + _request = build_restore_points_create_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, + 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 [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 = {} + 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 create( + def begin_create( self, resource_group_name: str, - ssh_public_key_name: str, - parameters: _models.SshPublicKeyResource, + restore_point_collection_name: str, + restore_point_name: str, + parameters: _models.RestorePoint, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + ) -> 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 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_07_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 + :param parameters: Parameters supplied to the Create restore point operation. Required. + :type parameters: ~azure.mgmt.compute.v2024_07_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: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create( + def begin_create( self, resource_group_name: str, - ssh_public_key_name: str, + restore_point_collection_name: str, + restore_point_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + ) -> 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 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. + :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: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create( + def begin_create( self, resource_group_name: str, - ssh_public_key_name: str, - parameters: Union[_models.SshPublicKeyResource, IO[bytes]], + restore_point_collection_name: str, + restore_point_name: str, + parameters: Union[_models.RestorePoint, IO[bytes]], **kwargs: Any - ) -> _models.SshPublicKeyResource: - """Creates a new SSH public key resource. + ) -> 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 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_07_01.models.SshPublicKeyResource or IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 + :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_07_01.models.RestorePoint or IO[bytes] + :return: An instance of LROPoller that returns either RestorePoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.RestorePoint] :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-07-01")) + 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, @@ -22179,126 +22813,135 @@ 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-07-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_restore_points_delete_request( resource_group_name=resource_group_name, - ssh_public_key_name=ssh_public_key_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, ) _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, 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("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_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 - :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_07_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_07_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 {}) - @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-07-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, + 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) - :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_07_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_07_01.models.SshPublicKeyUpdateResource or - IO[bytes] - :return: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + +class VirtualMachineScaleSetRollingUpgradesOperations: # 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_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` 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 _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, @@ -22307,66 +22950,112 @@ 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-07-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[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_update_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]: + 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_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. 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] + :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-07-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) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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 _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, @@ -22379,11 +23068,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-07-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_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, headers=_headers, @@ -22391,32 +23080,94 @@ 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_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: SshPublicKeyResource or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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-07-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, @@ -22429,11 +23180,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-07-01")) - cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_get_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, @@ -22441,102 +23192,102 @@ def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) ) _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 - @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. + @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. - :param resource_group_name: The name of the resource 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. Default value is None. - :type parameters: ~azure.mgmt.compute.v2024_07_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_07_01.models.SshPublicKeyGenerateKeyPairResult + :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 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. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) - :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_07_01.models.SshPublicKeyGenerateKeyPairResult - :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 @distributed_trace - 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. + 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. 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_07_01.models.SshGenerateKeyPairInputParameters or - IO[bytes] - :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.SshPublicKeyGenerateKeyPairResult + :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_07_01.models.RollingUpgradeStatusInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -22547,32 +23298,17 @@ 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-07-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.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) - _request = build_ssh_public_keys_generate_key_pair_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, - content_type=content_type, - json=_json, - content=_content, headers=_headers, params=_params, ) @@ -22589,7 +23325,7 @@ 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("RollingUpgradeStatusInfo", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -22597,14 +23333,14 @@ def generate_key_pair( return deserialized # type: ignore -class ImagesOperations: +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_07_01.ComputeManagementClient`'s - :attr:`images` attribute. + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models @@ -22617,8 +23353,167 @@ 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, 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_07_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-07-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 + + 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) + + 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, + vmss_extension_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.VirtualMachineScaleSetExtension: + """The operation to get the 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 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_07_01.models.VirtualMachineScaleSetExtension + :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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetExtension] = 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, + 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("VirtualMachineScaleSetExtension", 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 + 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, @@ -22638,14 +23533,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, @@ -22672,10 +23568,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 @@ -22683,25 +23584,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -22709,43 +23618,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_07_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_07_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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -22753,15 +23680,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -22773,33 +23701,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 = { @@ -22820,14 +23751,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, @@ -22854,10 +23786,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 @@ -22865,25 +23802,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -22891,25 +23836,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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -22917,21 +23869,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_07_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_07_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_07_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_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -22939,15 +23899,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -22959,29 +23920,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, @@ -22996,9 +23961,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-07-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, @@ -23022,21 +23988,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: @@ -23052,7 +24028,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, @@ -23067,7 +24044,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: @@ -23078,84 +24057,69 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- 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_07_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-07-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 - ) + ) + 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 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_07_01.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): + 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_07_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_07_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-07-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -23168,9 +24132,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, @@ -23195,7 +24163,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 @@ -23219,20 +24187,32 @@ 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_07_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" and "userData". Default value is None. + :paramtype expand: str or ~azure.mgmt.compute.v2024_07_01.models.InstanceViewTypes + :return: VirtualMachineScaleSetVM or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -23241,160 +24221,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 + _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-07-01")) + cls: ClsType[_models.VirtualMachineScaleSetVM] = 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) -class RestorePointCollectionsOperations: - """ - .. 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_07_01.ComputeManagementClient`'s - :attr:`restore_point_collections` 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("VirtualMachineScaleSetVM", pipeline_response.http_response) - @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. + 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: ~azure.mgmt.compute.v2024_07_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_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @overload - def create_or_update( + def _update_initial( self, resource_group_name: str, - restore_point_collection_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.VirtualMachineScaleSetVM, 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. 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_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - restore_point_collection_name: str, - parameters: Union[_models.RestorePointCollection, 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_07_01.models.RestorePointCollection or IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePointCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -23408,7 +24281,7 @@ def create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 @@ -23416,12 +24289,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, @@ -23431,156 +24307,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_07_01.models.RestorePointCollectionUpdate + :type parameters: ~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_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_07_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_07_01.models.RestorePointCollectionUpdate or - IO[bytes] - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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_07_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_07_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-07-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, 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) - _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 = 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.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 ) - 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 - 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, @@ -23596,10 +24534,12 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -23622,24 +24562,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: @@ -23655,7 +24611,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, @@ -23670,7 +24628,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: @@ -23684,30 +24644,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_07_01.models.RestorePointCollectionExpandOptions - :return: RestorePointCollection or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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, @@ -23720,221 +24659,113 @@ 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-07-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]: + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePointCollection", 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(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: - """Gets the list of restore point collections in a resource group. + 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. - :param resource_group_name: The name of the 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 RestorePointCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-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_07_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 + :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-07-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) - - _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 RestorePointsOperations: - """ - .. 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_07_01.ComputeManagementClient`'s - :attr:`restore_points` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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 = { @@ -23958,12 +24789,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, @@ -23982,7 +24813,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): @@ -23990,118 +24821,249 @@ 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_07_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_07_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_07_01.models.RestorePoint] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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. 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] + :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_07_01.models.StorageProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_attach_detach_data_disks( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + parameters: Union[_models.AttachDetachDataDisksRequest, IO[bytes]], + **kwargs: Any + ) -> 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. 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_07_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_07_01.models.StorageProfile] + :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-07-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, 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( + 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 + ) + 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) + 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.StorageProfile].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 + ) + + 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, + 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-07-01")) + cls: ClsType[Iterator[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 = 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) - :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 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_07_01.models.RestorePoint] - :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")) + + 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( - 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. + 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. - :param resource_group_name: The name of the resource 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_07_01.models.RestorePoint or IO[bytes] - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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: 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-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePoint] = 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_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, - 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, @@ -24110,31 +25072,89 @@ def begin_create( raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RestorePoint", 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.RestorePoint].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.RestorePoint]( - 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 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. 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_07_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-07-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) - def _delete_initial( - self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + _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 + + 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, @@ -24150,10 +25170,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_points_delete_request( + _request = build_virtual_machine_scale_set_vms_perform_maintenance_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, @@ -24169,7 +25189,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): @@ -24177,25 +25197,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, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any + def begin_perform_maintenance( + self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: - """The operation to delete the restore point. + """Performs maintenance 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 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 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: @@ -24209,10 +25235,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._perform_maintenance_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, @@ -24227,7 +25253,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: @@ -24241,31 +25269,15 @@ 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 _power_off_initial( self, resource_group_name: str, - restore_point_collection_name: str, - restore_point_name: str, + vm_scale_set_name: str, + instance_id: str, *, - expand: Optional[Union[str, _models.RestorePointExpandOptions]] = None, + skip_shutdown: Optional[bool] = None, **kwargs: Any - ) -> _models.RestorePoint: - """The operation to get the restore point. - - :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 - :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_07_01.models.RestorePointExpandOptions - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.RestorePoint - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24278,138 +25290,124 @@ 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-07-01")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_restore_points_get_request( + _request = build_virtual_machine_scale_set_vms_power_off_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, + 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 = 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("RestorePoint", 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_07_01.ComputeManagementClient`'s - :attr:`capacity_reservation_groups` attribute. - """ - - models = _models + 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")) - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - @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. + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - :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_07_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_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @overload - def create_or_update( + @distributed_trace + def begin_power_off( self, resource_group_name: str, - capacity_reservation_group_name: str, - parameters: IO[bytes], + vm_scale_set_name: str, + instance_id: str, *, - content_type: str = "application/json", + skip_shutdown: Optional[bool] = None, **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. + ) -> 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 - :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_07_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 + :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 {}) - @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. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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) - :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_07_01.models.CapacityReservationGroup or IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 + + 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, @@ -24418,131 +25416,122 @@ 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-07-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_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, - 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_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. 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_07_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_07_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-07-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) - :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_07_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 + + 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 update( + def _reimage_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, + vm_scale_set_vm_reimage_input: Optional[ + Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] + ] = 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_07_01.models.CapacityReservationGroupUpdate or - IO[bytes] - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_01.models.CapacityReservationGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -24556,19 +25545,23 @@ def update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", 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 + if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): + _content = vm_scale_set_vm_reimage_input else: - _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") + 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_capacity_reservation_groups_update_request( + _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, api_version=api_version, content_type=content_type, @@ -24579,105 +25572,175 @@ def 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]: + 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. + @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. + :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 + :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_07_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: """ - 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-07-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_capacity_reservation_groups_delete_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) - - _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 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. - 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 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 get( + def begin_reimage( 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. + ) -> 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 - :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_07_01.models.CapacityReservationGroupInstanceViewTypes - :return: CapacityReservationGroup or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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. + 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_07_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 = 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-07-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, + 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, @@ -24690,258 +25753,110 @@ 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-07-01")) - cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_capacity_reservation_groups_get_request( + _request = build_virtual_machine_scale_set_vms_reimage_all_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, 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( - 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. + 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. - :param resource_group_name: The name of the 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_07_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_07_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 + :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-07-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 + 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 ) - 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_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. - - :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_07_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_07_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_07_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-07-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_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) - - 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 + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("CapacityReservationGroupListResult", 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) - - _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 CapacityReservationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.compute.v2024_07_01.ComputeManagementClient`'s - :attr:`capacity_reservations` attribute. - """ - - models = _models + 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, @@ -24951,30 +25866,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-07-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, ) @@ -24988,7 +25891,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): @@ -24996,124 +25899,49 @@ 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, - 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. - - :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_07_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_07_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. 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_07_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. + 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_07_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_07_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-07-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, @@ -25122,35 +25950,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_07_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-07-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 = { @@ -25174,12 +26072,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, @@ -25206,99 +26104,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_07_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_07_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_07_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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. + ) -> 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. + :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_07_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.CapacityReservation] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -25306,15 +26209,15 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -25327,34 +26230,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-07-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, @@ -25370,10 +26327,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -25389,7 +26346,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): @@ -25397,31 +26354,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: @@ -25435,10 +26392,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, @@ -25453,7 +26410,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: @@ -25467,31 +26426,50 @@ 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 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_07_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 get( + def list( self, resource_group_name: str, - capacity_reservation_group_name: str, - capacity_reservation_name: str, + vm_scale_set_name: str, + instance_id: 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.VirtualMachineScaleSetVMExtensionsListResult: + """The operation to get all extensions of an instance in Virtual Machine Scaleset. - :param resource_group_name: The name of the resource 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_07_01.models.CapacityReservationInstanceViewTypes - :return: CapacityReservation or the result of cls(response) - :rtype: ~azure.mgmt.compute.v2024_07_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 + :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_07_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -25506,12 +26484,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-07-01")) - cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) - _request = build_capacity_reservations_get_request( + _request = build_virtual_machine_scale_set_vm_extensions_list_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, expand=expand, api_version=api_version, @@ -25531,7 +26509,9 @@ 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( + "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -25539,27 +26519,87 @@ def get( 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. + def get( + self, + resource_group_name: str, + vm_scale_set_name: str, + instance_id: str, + vm_extension_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> _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 - :return: An iterator like instance of either CapacityReservation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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_07_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 {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-01")) - cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = 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, + 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("VirtualMachineScaleSetVMExtension", 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, + vm_extension_name: str, + extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -25568,83 +26608,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-07-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")) + + 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_07_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_07_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. - 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_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_07_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_07_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_07_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_07_01.ComputeManagementClient`'s - :attr:`log_analytics` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -25664,13 +26848,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, @@ -25689,7 +26876,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): @@ -25697,79 +26884,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_07_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_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.LogAnalyticsOperationResult] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -25777,14 +27005,17 @@ def begin_export_request_rate_by_interval( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -25796,32 +27027,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, @@ -25831,28 +27067,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-07-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, ) @@ -25866,7 +27093,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): @@ -25874,93 +27101,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_07_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_07_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_07_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_07_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_07_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-07-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, @@ -25969,40 +27155,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_07_01.ComputeManagementClient`'s - :attr:`virtual_machine_run_commands` attribute. + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models @@ -26016,22 +27198,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_07_01.models.RunCommandDocumentBase] + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -26044,9 +27241,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, @@ -26071,7 +27271,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 @@ -26095,15 +27295,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_07_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_07_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -26118,12 +27334,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-07-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, @@ -26141,7 +27360,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 @@ -26151,7 +27370,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 @@ -26179,9 +27399,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, @@ -26209,10 +27430,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 @@ -26220,21 +27446,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. @@ -26253,27 +27482,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) @@ -26286,19 +27518,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. @@ -26321,7 +27556,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, @@ -26341,7 +27577,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: @@ -26360,7 +27598,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 @@ -26388,9 +27627,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, @@ -26418,10 +27658,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 @@ -26429,24 +27673,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_07_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -26462,27 +27708,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) @@ -26495,22 +27743,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_07_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of @@ -26531,7 +27782,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, @@ -26545,13 +27797,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: @@ -26568,7 +27827,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, @@ -26584,9 +27843,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -26611,25 +27871,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] @@ -26646,7 +27913,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, @@ -26662,7 +27930,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: @@ -26676,28 +27946,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_07_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_07_01.models.VirtualMachineRunCommand + :return: VirtualMachineExtensionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -26712,12 +27996,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-07-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, @@ -26737,7 +28020,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 @@ -26745,29 +28028,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_07_01.models.VirtualMachineRunCommand] + :return: VirtualMachineExtension or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2024_07_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-07-01")) - cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -26776,89 +28060,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-07-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_07_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 = { @@ -26879,16 +28122,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, @@ -26915,10 +28157,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 @@ -26926,34 +28173,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -26961,34 +28206,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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -26996,29 +28239,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -27026,17 +28268,16 @@ def begin_create_or_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -27048,35 +28289,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 = { @@ -27097,16 +28339,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, @@ -27133,10 +28374,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 @@ -27144,34 +28389,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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -27179,65 +28423,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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_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_07_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_07_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_07_01.models.VirtualMachineRunCommand] + ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2024_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -27245,17 +28485,16 @@ def begin_update( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -27267,30 +28506,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, @@ -27306,11 +28552,10 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2024-07-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, @@ -27334,27 +28579,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: @@ -27370,9 +28619,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, @@ -27387,7 +28635,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: @@ -27400,171 +28650,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_07_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-07-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_07_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-07-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 cad0623e3cd5..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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.